Write a Numerical Program to Find the Value of Integration of a Function Using Trapezoidal Rule in Using C Language
Programs :
#include<stdio.h>
#include<conio.h>
float f(float x)
{
return(x*x*x) ;
}
void main( )
{
float x0,xn,h,sum=0.0,sum1=0.0,res;
int n,i;
clrscr( );
printf("\nEenter the lower limit and upper limit\n");
scanf("%f%f",&x0,&xn);
printf("\nEenter the no. of intervals\:n");
scanf("%d",&n);
h=(xn-x0)/n;
sum+=f(x0)+f(xn);
for(i=1;
res=(h/3.0)*(sum+sum1);
printf("\nThe value of the integration is =%f",res);
getch( );
}
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment