info@thistimebd.com

Thursday 21st of November 06:34:43pm

Define an array, data, with 100 elements of type double. Write a loop that will store the following sequence of values in corresponding elements of the array: 1/(2*3*4) 1/(4*5*6) 1/(6*7*8) ... up to 1/(200*201*202) Write another loop that will calculate the following: data[0]-data[1]+data[2]-data[3]+... -data[99] Multiply the result of this by 4.0, add 3.0, and output the final result. Do you recognize the value that you get?

Define an array, data, with 100 elements of type double. Write a loop that will

store the following sequence of values in corresponding elements of the array:

1/(2*3*4) 1/(4*5*6) 1/(6*7*8) ... up to 1/(200*201*202) Write another loop that

will calculate the following: data[0]-data[1]+data[2]-data[3]+... -data[99] Multiply

the result of this by 4.0, add 3.0, and output the final result. Do you recognize the

value that you get?


Solution:

#include<stdio.h>

int main()

{

int i;

double data[100];

double sum=0.0;

double sign=1.0;

for(i=1; i<=100; i++)

{

data[i-1]=1.0/(2*i*(2*i+1)*(2*i+2));

}

for(i=0; i<100; i++)

{

sum += sign*data[i];

sign=-sign;

}

printf("The result is %lf ",4.0*sum+3);

printf(" I Reconize this num this is pi num ");

}