C PROGRAM FOR FINDING COS THETA
Actually, I've made the program. but it still doesn't work well...the task is from my lecturer.. the task is about the function. after I enter the real number X and an integer number N. the program computes the value for Z, using factoring over N terms. the program also prints out the value of Z, cos(Z), and the N-th term. only use the function, not the pointer and the array..
CODE:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ACC 0.0001
#define PI 3.14
void main()
{
int x,i;
float x1,x2,cosz=0,term;
clrscr();
printf("Enter the X value:");
scanf("%d",&x);
x1=(x*PI)/180;
// printf("%f",cos(x1));
x2=x1*x1;
term=1;
cosz=term;
for(i=2;fabs(term)>ACC;i=i+2)
{
term = (x2*(-term))/(i*(i-1));
cosz = cosz+term;
}
printf("\nNew Value%f",cosz);
getch();
}

0 comments:
Post a Comment