example2_trigonometric_functions.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include <iostream>
#include <cmath>

int main() {
    double angle = M_PI / 4; // 45 degrees in radians

    std::cout << "Sine of 45°: " << std::sin(angle) << std::endl;
    std::cout << "Cosine of 45°: " << std::cos(angle) << std::endl;
    std::cout << "Tangent of 45°: " << std::tan(angle) << std::endl;

    double value = 0.5;
    std::cout << "Arcsine of 0.5: " << std::asin(value) << " radians" << std::endl;
    std::cout << "Arccosine of 0.5: " << std::acos(value) << " radians" << std::endl;
    std::cout << "Arctangent of 1: " << std::atan(1) << " radians" << std::endl;

    return 0;
}
Back to cmath