# COS Function in C

The C cos Function is a Math Library Function, used to calculate the Trigonometry Cosine value for the specified expression. The syntax of the cos is

`double cos(double number);`

The COS function in C will return the value between -1 and 1. Before we get into to the syntax, let us see the mathematical formula behind this C Trigonometry Cosine function:

cos(x) = Length of the Adjacent Side / Length of the Hypotenuse

## COS Function in C Example

The cos function in the math library allows you to find the trigonometry Cosine for the specified values.

This C program, ask the user to enter his/her own value, and then it will find the cosine value of the user-specified one

TIP : Please refer C ACOS Function article in C Programming to calculate the Arc Cosine of the specified expression.

```#include <stdio.h>
#include <math.h>

int main()
{
double cosValue, number;
printf(" Please Enter the Value to calculate Cosine :  ");
scanf("%lf", &number);

cosValue = cos(number);

printf("\n Cosine value of %lf = %f ", number, cosValue);

return 0;
}```

## C COSINE Function Example 2

In this C cosine function example, we are allowing the user to enter the value in degrees. Then we are converting the degrees to Radians. And finally, we are finding the cosine value of the radian.

```#include <stdio.h>
#include <math.h>

#define PI 3.14
int main()
{
printf(" Please Enter an Angle in degrees :  ");
scanf("%lf", &degreeVal);

// Convert Dgree Value to Radian
`````` Please Enter an Angle in degrees :  35