WAP to calculate the value of sine using Maclaurin Expansion

Write a program to calculate the value of sine using Maclaurin Expansion using for loop

#include<stdio.h>

int main() {
	float i,term,x,r,sum,n;
	printf("Enter degree: ");
	scanf("%f",&x);
	printf("Enter term: ");
	scanf("%f",&n);
	r=x*3.141592/180;
	term=r;
	sum=r;
	for(i=1;i<=n-1;i++) {
		term*=(-1)*r*r/((2*i)*(2*i+1));
		sum+=term;
	}
	printf("Valuve of Sin%f = %f",x,sum);
}

Output

WAP to calculate the value of sine using Maclaurin Expansion
Value of sin(90)

Behind the scene

WAP to calculate the value of sine using Maclaurin Expansion
Maclaurin Expansion of sin(90)
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments