English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

can anyone tell me ,how do u write a c program to find the value of cosx only by using the infinte series expansion i.e.,
1- ((x^2)/2!)+((x^4)/4!)........infinity.

2006-09-19 20:07:10 · 3 answers · asked by vish 1 in Computers & Internet Programming & Design

3 answers

#include
#include
#include

long int fact(int n)
{

int i;
long int x=1;
for (i=1;i<=n;i++){
x=x*i;

}
return x; }


main(){
double x,sum;
int n,i,a,k;

do {
system("cls");
do {

printf("\n\nEnter the number of terms [0..16] : ");
scanf("%d",&n);

} while (n>16);
printf("Enter the angle in degrees : ");
scanf("%d",&a);

x=a/180.0*3.14;
printf("\n angle in radian = %f \n\n",x) ;
sum=0.0;


for (i=0;i<=n;i++){
printf("\n\n\n Term = %d ",i);
k=2*i;
printf("\n sign = %f ",pow(-1,i)) ;
printf("\n% angle to the power 2 times %d = %f ",i,pow(x,k)) ;
printf("\n factorial of 2 times %d = %d ",i,fact(k)) ;

sum=sum+pow(-1,i)*(pow(x,k)/fact(k));

}

printf("\n\n cos(%d) = %f \n\n",a,sum);
system("pause");
}while (1 !=2);

}

2006-09-19 20:14:31 · answer #1 · answered by iyiogrenci 6 · 0 0

I majored in lit in employer. i could say for this poem, you prefer some historic previous on the poet. It starts out kinda unhappy, with the view. 'Futures i've got divorced' maximum like refers to abandoned hopes and desires. The 'do no longer look back' and knife reference is in many situations approximately getting over painful memories. That it now no longer cuts implies desire. Or in all probability numbness. The stuff on complacency generally attitude he feels he enable all people down by utilising no longer doing something he could desire to have executed. hence the accusatory voices. The final paragraph is a little extra complicated. My adventure is that the narrator got here upon his existence training and acted hence, in this undertaking the great reward. This guy sounds like a soldier to me. person who believes that no longer taking action at some necessary 2d further on others harm. Now he's grew to become that physique of techniques around, and observed some peace. He gave up historical and futile attempts and took a various technique to existence, and he's initiating to look for out his existence extra worthwhile. i do no longer oftentimes like poems, yet my mothers and fathers spents hundreds that they did no longer have so i could discover ways to interpret then. i'm extra approximately novels, inspite of the incontrovertible fact that. as quickly as extra, you are able to a selection of of the time progression from determining something of this author's existence. This one is captivating private, previous the known sense of the sweetness and cruelty of the international I many times see in lesser poems.

2016-10-17 07:51:39 · answer #2 · answered by Anonymous · 0 0

Although it is possible, you must bound your factorials so they do not overflow.

16! is 20922789888000.

An unsigned long will go up to 18,466,744,073,709,551,615, so your precision could only go to 16!, since 32! would be too large.

Write a factorial function (this can be done iteratively or recursively) and you can write a power function (same thing.. iterative or recursive).

Best of luck.

2006-09-19 20:33:34 · answer #3 · answered by bahamutxd 3 · 0 0

fedest.com, questions and answers