Write a C program to calculate the following sum:
sum = 1 – x2 /2! + x4 /4! – x6 /6! +x8 /8! – x10/10!

Program Code:
#include<stdio.h>
#include<math.h>
void main()
{

int i = 2, n, s = 1, x, pwr = 1, dr;
float nr = 1, x1, sum;
printf("\n\n\t enter the angle...: ");
scanf("%d", &x);
x1 = 3.142* (x /180.0);
sum = x1;
printf("\n\t enter the number of terms...: ");
scanf("%d", &n);
While ( i <= n )
{
pwr = pwr + 2;
dr = dr * pwr * (pwr - 1);
sum = sum + (nr / dr) * s;
s = s * (-1);
nr = nr * x1 * x1; i+= 2;
}
printf("\n\t the sum of the sine series is..: %0.3f",sum);
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: