#include <iostream>
#include <cmath>
int main() {
// Compute the square root of a number
double num = 4.0;
double sqrt_num = sqrt(num);
std::cout << "The square root of " << num << " is " << sqrt_num << std::endl;
// Compute the sine of an angle in radians
double angle = M_PI / 4; // M_PI is a predefined constant for pi
double sin_angle = sin(angle);
std::cout << "The sine of " << angle << " radians is " << sin_angle << std::endl;
// Compute the absolute value of a number
double neg_num = -5.0;
double abs_num = abs(neg_num);
std::cout << "The absolute value of " << neg_num << " is " << abs_num << std::endl;
// Round a number up to the nearest integer
double decimal = 3.7;
int rounded_up = ceil(decimal);
std::cout << "The number " << decimal << " rounded up is " << rounded_up << std::endl;
return 0;
}
0 Comments