answersLogoWhite

0

ITS EASY...

TRY THIS OUT..

TRAPEZOIDAL METHOD

#include

#include

#include

float valcal(float x){

return (x*x*x);

}

int main(){

float a,b,h,c,I;

int n,i;

printf("THE TRAPEZOIDAL RULE:\n");

printf("---------------------");

printf("\n\n\nEnter the two limits and the no. of divisions:\n");

scanf("%f %f %d",&a, &b, &n);

h=(b-a)/n;

//printf("\nVALUE of h: %f\n", h);

c=a;

I=valcal(a)+valcal(b);

//printf("\nVALUE FOR a: %f\n", valcal(a));

//printf("\nVALUE FOR b: %f\n", valcal(b));

for(i=1;i

c=c+h;

//printf("\nValue of c for loop %d: is %f\n ",i,c);

if(c>=b){

printf("\n\nc>b\n\n");

break;

}

//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));

I=I+(2*valcal(c));

//printf("\nI right now is %f", I);

}

printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/2);

printf("\n\n\n");

system("pause");

}

SIMPSON'S 1/3RD METHOD

#include

#include

#include

float valcal(float x){

return (1/(1+x*x));

}

int main(){

float a,b,h,c,I;

int n,i;

printf("THE SIMPSON'S ONE-THIRD RULE:\n");

printf("------------------------------");

printf("\n\n\nEnter the two limits and the no. of divisions:\n");

scanf("%f %f %d",&a, &b, &n);

h=(b-a)/n;

//printf("\nVALUE of h: %f\n", h);

c=a;

I=valcal(a)+valcal(b);

//printf("\nVALUE FOR a: %f\n", valcal(a));

//printf("\nVALUE FOR b: %f\n", valcal(b));

for(i=1;i

c=c+h;

//printf("\nValue of c for loop %d: is %f\n ",i,c);

if(c>b){

printf("\n\nc>b\n\n");

break;

}

//printf("\nVALUE FOR %f: is %f\n",c, valcal(c));

if(i%2==0)

I=I+(2*valcal(c));

else

I=I+4*valcal(c);

//printf("\nI right now is %f", I);

}

printf("\n\n\nThe integration of x*x*x is: %f",(h*I)/3);

printf("\n\n\n");

system("pause");

}

NEED MORE HELP...

MAIL ME YOUR PROB... SEE YA

User Avatar

Wiki User

14y ago

What else can I help you with?