Program to find sinx=x-x33!+x55!+x77! Upto n term.

 Program to find sinx=x-x33!+x55!+x77! Upto n term.


#include<stdio.h>

#include<math.h>

main()

{

int n,count=1,i,j,sin=1,ang;

float x,sum=0,term,nr;

double dr;

clrscr();

printf("\nEnter the angle:\n");

scanf("%d",&ang);

printf("\nEnter the number of terms\n");

scanf("%d",&n);

x=ang*3.14/180;

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

{

nr=pow(x,count);

dr=1;

for(j=1;j<=count;j++)

dr=dr*j;

term=sin* nr/dr;

sum=sum+term;

count=count+2;

sin=-1*sin;

}

printf("\nSin(%d)= %f",ang,sum);

getch();

}



Output:


  1. Enter the angle:

20

Enter the number of terms

8

Sin(20)= 0.341854


  1. Enter the angle:

46

Enter the number of terms

5

Sin(46)= 0.719057




Post a Comment

Previous Post Next Post