Function name : cos
Header file : <math.h>
Function prototype : double cos(double x);
Function : cosine function
Parameters : double x The arc to be operated on
Return value : Returns the cosine of x radians
Formula : 1°=π/180°radians
Note : cos() is a known radian value x of an angle, and finds the cosine value y of the angle.
Program example : Find the cosine of a 60-degree angle and output the result
#include<math.h>#include<stdio.h>#definePI3.14159265intmain(void){doubleresult;doublex=60*PI/180;//Convert 60-degree angle to radians result=cos(x);printf( Thecosineof%lfis%lfn,x,result);return0;}
Running results:
Thecosineof1.047198is0.500000