![]() |
cos() function in C programming is provided by the math.h header file and is used to calculate the cosine of an angle (x) where (x) is represented in radians. This function returns the cosine of a given angle value in radians for a right-angled triangle. Syntax of cos()double cos(double x); Parameters of cos()The cos(x) function takes a single parameter x, where:
Return value of cos()The cos(x) function returns the cosine of the given angle x which is passed in the form of radians. Example of cos() in CInput: The below program demonstrates how we can calculate the cosine of various angles in C.
Output The Cosine of 0.524 radians (30 degrees) is 0.866 Time Complexity: O(1) Explanation: In the above program M_PI is a macro constant defined in the <math.h> header which represents the mathematical constant π (pi) which is approximately equal to 3.14159265358979323846 |
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 20 |