Posts

Showing posts from February 3, 2019

C Program to calculate value using composite trapezoidal rule | C Programming

C programming to calculate value using composite trapezoidal rule #include<stdio.h> #include<conio.h> #include<math.h> #define F(x) 2*x int main() { int n,i; float a,b,h,x,sum=0,integral; printf("Enter the two limits:\n"); scanf("%f%f",&a,&b); printf("Enter the difference n:\n"); scanf("%d",&n); h=(b-a)/n; for(i=1;i<n;i++) { x=a+i*h; sum=sum+F(x); } integral=(h/2)*(F(a)+F(b)+2*sum); printf("\nThe integral is: %f\n",integral); return 0; }

C Programming Codes To Compute Value Using Trapezoidal Rule

C Programming Codes To Compute Value Using Trapezoidal Rule #include<stdio.h> #include<conio.h> #include<math.h> #define F(x) exp(-(x/2)) int main() { int a,b,h; float i,x,y; printf("Enter the value for lower and upper limit\n"); scanf("%d%d",&a,&b); h=b-a;//Calculating height x=F(a);//Calculation Function and storing in x and y. y=F(b); i=h*((x+y)/2); printf("The Intregrated Value is %.3f",i); }