cos function(Cosine) in C Language – example and detail

In the C Programming Language, the cos feature returns the cosine of x.


The syntax for the cos feature in the C Language is:

double cos(double x);

Parameters or Arguments


A value expressed in radians (not degrees).


The cos function returns the cosine of x, measured in radians.

Required Header

In the C Language, the required header for the cos feature is:

#include <math.h>

Applies To

In the C Language, the cos characteristic can be used in the following versions:

ANSI/ISO 9899-1990

cos Example

/* Example using cos by */

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

int main(int argc, const char * argv[])
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the cos of */
    value = 0.5;

    /* Calculate the Cosine of value */
    result = cos(value);

    /* Display the result of the calculation */
    printf("The Cosine of %f is %f\n", value, result);

    return 0;

When compiled and run, this utility will output:

The Cosine of 0.500000 is 0.877583

Similar Functions

Other C features that are comparable to the cos function:

acos characteristic asin characteristic atan characteristic atan2 characteristic sin feature tan feature