Community Sites
Create your own community website and start earning today !
It's Free !
 
Communities Members BookmarksPolls Fresher Jobs Strange Photos Academic Projects New Member FAQ  



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.

website counter




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.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C++ Program to solve linear equation (3 variable) by gauss elimination method
Previous Resource: C++ Program for probability 1
Return to Discussion Resource Index
Post New Resource
Category: Computer & Technology


Post resources and earn money!
 
Related Resources

Watch TV Channels



Contact Us    Editors    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.