Convert Degrees to Radians using C++

Calculate by formula

#include <iostream>
#include <cmath>

double degreesToRadians(double degrees)
{
    return degrees * M_PI / 180;
}

int main()
{
    double degrees = 180;
    double radians = degreesToRadians(degrees);

    std::cout << radians << std::endl;

    return 0;
}

Leave a Comment

Cancel reply

Your email address will not be published.