Header file:
math.h
Synopsis:
double cos(double x);
Description:
Returns cosine value of x.
cos function in C example
#include<stdio.h>
#include<math.h>
int main() {
/*
* degree to radian conversion
* radian = degree * PI/180;
*/
double deg, radian;
printf("Enter your input:");
scanf("%lf", °);
deg = deg * (3.14 / 180);
radian = cos(deg);
printf("Result: %lf\n", radian);
return 0;
}
#include<math.h>
int main() {
/*
* degree to radian conversion
* radian = degree * PI/180;
*/
double deg, radian;
printf("Enter your input:");
scanf("%lf", °);
deg = deg * (3.14 / 180);
radian = cos(deg);
printf("Result: %lf\n", radian);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/math$ gcc cos.c -lm
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:0
Result: 1.000000
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter your input:0
Result: 1.000000
No comments:
Post a Comment