My Profile
Active Members
TodayLast 7 Days
more...
Awards & Gifts
Online Exams
Fresher Jobs
Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian
cities including Bangalore, Chennai, Hyderabad, Pune or Kochi
Resources
Find educational articles, blogs, discussion threads and other resources.
Colleges
Find details about any college in India or search for courses.
|
C++ PROGRAM FOR INTEGRATION USING NUMERICAL METHODS
Posted Date: 23 Mar 2008 Resource Type: Articles/Knowledge Sharing Category: Computer & Technology
|
Posted By: ashish singh Member Level: Diamond Rating: Points: 4
|
|
|
|
//PROGRAM FOR INTEGRATION USING NUMERICAL METHODS
#include #include #define f(x) sqrt(cos(x)) #define inv 10 #include void main() { clrscr(); int choice; float l,j=0,u,h,arr[inv+1],sum1=0,sum2=0,sum3=0,res=0; textcolor(GREEN); cprintf("INTEGRATION USING THE TRAPEZOIDAL RULE & SIMPSON'S 1/3rd RULE"); cout<<"\n"; textcolor(BLUE); cprintf("1.TRAPEZOIDAL RULE"); cout<<"\n"; cprintf("2.SIMPSON'S 1/3rd RULE"); cout<<"\nenter your choice :"; cin>>choice;
cout<<"enter the lower and upper limit respectively\n"; cin>>l>>u; j=l; h=(u-l)/inv; for(int i=0;i<=inv;i++) { arr[i]=f(j);//cout<<"\n"<j=j+h; }
sum1=arr[0]+arr[inv];
switch(choice) { case 1: cout<<"\n================================================================================\n"; for(i=1;i {sum2+=arr[i];} res=h/2*(sum1+2*sum2); cout<<"\nthe integration is :"< break; case 2: cout<<"\n================================================================================\n"; for(i=1;i { sum2+=arr[i];} for(i=2;i {sum3+=arr[i];} res=h/3*(sum1+4*sum2+2*sum3); cout<<"\nthe integration is :"< break; default:cprintf("WRONG CHOICE "); } cout<<"\n"; cprintf("PROGRAM DESIGNED BY:ROHIT KUMAR"); cout<<"\n"; textcolor(RED); cprintf("BRANCH : ECE / 3rd semester / roll 249/06 ");
getch(); }
output:
INTEGRATION USING THE TRAPEZOIDAL RULE & SIMPSON'S 1/3rd RULE 1.TRAPEZOIDAL RULE 2.SIMPSON'S 1/3rd RULE enter your choice :1 enter the lower and upper limit respectively 0 1.57
================================================================================
the integration is :1.187191 PROGRAM DESIGNED BY:ROHIT KUMAR BRANCH : ECE / 3rd semester / roll 249/06
INTEGRATION USING THE TRAPEZOIDAL RULE & SIMPSON'S 1/3rd RULE 1.TRAPEZOIDAL RULE 2.SIMPSON'S 1/3rd RULE enter your choice :2 enter the lower and upper limit respectively 0 1.57
================================================================================
the integration is :1.19437
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|
Watch TV Channels
|