#include<stdio.h>
#include<conio.h>
float f(float x){
float r;
r=2*x+1;
return r;
}
void main(){
float output;
float a,b;
float h,s;
int i,j;
int n;
clrscr();
printf("===========================================\n");
printf(" SIMPSON'S ONE-THIRD RULE\n");
printf("===========================================\n");
printf("Enter the integral limit:-\n");
printf("-------------------------------------------\n");
printf("Lower limit value a: \n");
scanf("%f",&a);
printf("Upper limit value b: \n");
scanf("%f",&b);
printf("-------------------------------------------\n");
printf("Enter number of total intervals: \n");
scanf("%d",&n);
h=0.0;
h=(b-a)/(2*n);
printf("____________________________________________\n");
printf("Resultant value of h is %.2f \n",h);
s=0.0;
s=f(a)+f(b)+4*f(a+h);
printf("Resultant value of f(a) + f(b) is %.2f \n",s);
for (i=3;i<2*n;i+=2)
{
s+=2*f(a+(i-1)*h)+4*f(a+i*h);
}
printf("Resultant value of whole summation of f(-) is %.2f\n",s);
output=1;
output=(h/3)*s;
printf("Output value of the integral is %.2f \n",output);
printf("____________________________________________\n");
printf(" GOOD LUCK\n");
getch();
}
Thank you so much for this excellent post here . well-done guy .
ReplyDeleteThank you guy you have published this awesome post with us.
ReplyDeleteThis was really helpful to us coders. It was very informative thank you.
ReplyDeletemy website-
Clipping Path Service provider company
photo retouching services
Image Background Remove Blog
How to do clipping path service
Ghost mannequin service
aydın
ReplyDeleteizmir
çankırı
giresun
konya
VH56EE