Question:

Published on: 13 November, 2024

**Write a C program to find the value of Sine(X).**

Answer:

#include<stdio.h> #include<conio.h> #include<math.h> int sine(int); int fact(int); void main() { int x; float result; clrscr(); printf("Enter the value to calculate Sin(x) : "); scanf("%d",&x); result = sine(x); printf("The value of Sin(%d) = %f",x,result); getch(); } int sine(int x) { int i=1,n,m,a,b,cond=0; float temp=0; printf("\nEnter the iteration : "); scanf("%d",&n); for(m=1;m<=n;m++) { a = pow(x,i); printf("%d\n",a); b = fact(i); printf("%d",b); if(cond%2==0) { temp = temp+(a/b); printf("%d\n",temp); cond = cond+1; } else { temp = temp-(a/b); printf("%d\n",temp); cond = cond+1; } i = i+2; } return temp; } int fact(int p) { if(p==0) return(1); else { p = p*fact(p-1); } printf("\nFact = %d",p); return(p); }

Subjects

Trending

**Write a C- Program To Count The Lines, Words, Characters In A Given Text.**

View : 743

13 November, 2024

Random questions

**Explain the LOC, Function point and Feature point? **

13 November, 2024

How insertion sort and selection sorts are different?

23 January, 2022

What operations can be performed on Queues?

23 January, 2022

Find the time complexity of Binary Search Algorithm.

13 November, 2024

13 November, 2024