How to use the function acos() in C

1 Answer

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

// double acos(double x); // returns the arc cosine in radians.

int main() {
    double value = 0.5; // Input value for acos (must be in the range [-1, 1])
    double result;

    // Compute the arccosine
    result = acos(value);

    // Print the result in radians
    printf("The arccosine of %.2f is %.2f radians.\n", value, result);

    // Convert radians to degrees
    double result_in_degrees = result * (180.0 / M_PI);
    printf("The arccosine of %.2f is %.2f degrees.\n", value, result_in_degrees);

    return 0;
}



/*
run:

The arccosine of 0.50 is 1.05 radians.
The arccosine of 0.50 is 60.00 degrees.

*/

 



answered May 16, 2025 by avibootz

Related questions

2 answers 357 views
2 answers 430 views
2 answers 402 views
1 answer 258 views
258 views asked Aug 27, 2016 by avibootz
1 answer 262 views
...