C Language: acos function(Arc Cosine)

C Programming allows us to perform mathematical operations through the functions defined in header file. The header file contains various methods for performing mathematical operations such as sqrt(), pow(), ceil(), floor() etc.

C Math Functions

In the C Programming Language, the acos function returns the arc cosine of x.

Syntax

The syntax for the acos function in the C Language is:




double acos(double x);



Parameters or Arguments

A value between -1 and 1. A domain error will occur if x is not between -1 and 1.

Returns

The acos function returns the arc cosine of a number represented by x. It will return a value between 0 and π.

Required Header

In the C Language, the required header for the acos function is:




#include <math.h>



Applies To

In the C Language, the acos function can be used in the following versions

  • ANSI/ISO 9899-1990

acos Example




/* Example using acos by c programming */

#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 acos of */
    value = 0.5;

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

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

    return 0;
}



When compiled and run, this application will output:

The Arc Cosine of 0.500000 is 1.047198




Instagram