Write a C program to find the value of Sine(X).
#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); }
Write a C program to print the following output.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Implement Bubble Sort using C.
Write a C program to transpose of a matrix.