www.flickr.com

Codes for Trapezoidal Rule in C and C++

Tuesday, October 15, 2013 Posted by Glenn

 #include<stdio.h>  
 #include<conio.h>  
 #include<math.h>  
 float fn(float x)  
 {  
 sqrt(x);  
 return sqrt(x);  
 }  
 main()  
 {  
 int i,n;  
 float a,b,s=0,y=0,h;  
 printf("Enter the no of interval =");  
 scanf("%d",&n);  
 printf("Enter the lower limit=");  
 scanf("%f",&a);  
 printf("Enter the upper limit=");  
 scanf("%f",&b);  
 h=(b-a)/n;  
 for(i=1;i<=n-1;i++)  
 {  
 s=s+fn(a+i*h);  
 }  
 y=(fn(a)+fn(b)+2*s)*h/2;  
 printf("the value of y is=%f",y);  
 getch();  
 }  

-this source codes belongs to: the author of wbutassignmenthelp :)
-this source codes is ready for copy-paste to any IDE/compilers for C/C++. The quotations from the original website source confuse the compilers, I've already change them to the original quotation :)
additional tags: trapezoidal rule for C, trapezoidal rule for Cplusplus, C++, codes for Trapezoidal, trapezoidal source codes

glenn von

Author: Glenn Posadas

20 year old 5th year Computer Engineering Student, a blogger, photographer, programmer, and an electronics hobbyist; a Christian who loves God very much..

Sharing is so Easy:
StumpleUpon DiggIt! Del.icio.us Blinklist Yahoo Furl Technorati Simpy Spurl Reddit Google Twitter FaceBook

Post a Comment

Drop a comment. Thank you guys!