You are on page 1of 1

/*CC-14 Numerical Methods Practical 2021

NAME: PRABHAKAR SONAR


CU ROLL NO: 183613-21-0045
PROGRAM FOR TRAPEZOIDAL RULE
PROGRAM NO: TRPZ - 21
Date Of Submission: 29 /06/2021*/
#include<stdio.h>
#include<math.h>
#include<conio.h>

float f(float x)
{
float g,l;
g=pow(((sinh(2*x+1))/(pow(x,2)+21.0)),1/3.0);
return(g);
}
main()
{
float a,b,h,x,sum,I;
int i,n;
float f(float x);
clrscr();
printf("Enter lower limit : ");
scanf("%f",&a);
printf("Enter Upper limit : ");
scanf("%f",&b);
printf("Enter number of intervals n : ");
scanf("%d",&n);
h=(b-a)/n;
sum=0.0;
for(i=1;i<=n-1;i++)
{
x=a+h*i;
sum=sum+f(x);
}
I=(h/2.0)*(f(a)+f(b)+2*sum);
printf("Value of the integral is = %f",I);
getch();
}

OUTPUT :

Enter lower limit : 0.1


Enter Upper limit : 0.2
Enter number of intervals n : 12
Value of the integral is = 0.043232

You might also like