NOTE :
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float x,sum,term;
int i,n;
clrscr();
printf("\nEnter the value of n\t:\t");
scanf("%d",&n);
printf("\nEnter the value of x in degrees\t:\t");
scanf("%f",&x);
x=(x*3.14)/180;
sum=x;
term=x;
for(i=1;i<n;i++)
{
term=(term*(-1)*x*x)/((2*i)*(2*i+1));
sum=sum+term;
}
printf("\nSin value of given angle is %f",sum);
getch();
}
OUTPUT :
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
float x,sum,term;
int i,n;
clrscr();
printf("\nEnter the value of n\t:\t");
scanf("%d",&n);
printf("\nEnter the value of x in degrees\t:\t");
scanf("%f",&x);
x=(x*3.14)/180;
sum=x;
term=x;
for(i=1;i<n;i++)
{
term=(term*(-1)*x*x)/((2*i)*(2*i+1));
sum=sum+term;
}
printf("\nSin value of given angle is %f",sum);
getch();
}
OUTPUT :


0 comments: