Repository navigation
Expand file tree
/
Copy pathmath.cpp
More file actions
32 lines (28 loc) · 1.48 KB
/
Copy pathmath.cpp
File metadata and controls
32 lines (28 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <cmath> // Include the cmath library for mathematical functions
/*
This program demonstrates the use of various mathematical functions in C++.
The cmath library provides a wide range of functions for performing mathematical operations.
Some of the commonly used functions include:
- sqrt(): Computes the square root of a number.
- pow(): Computes the power of a number.
- abs(): Computes the absolute value of a number.
- sin(), cos(), tan(): Compute the sine, cosine, and tangent of an angle (in radians).
- log(): Computes the natural logarithm of a number.
*/
int main(){
double x = 3;
double y = 4;
double z;
// z = std::max(x,y); // Use the max function to find the maximum of x and y
// z = std::min(x,y); // Use the min function to find the minimum of x and y
// z = std::pow(2,4); // Use the pow function to compute x raised to the power of y
// z = sqrt(16); // Use the sqrt function to compute the square root of a number
// z = abs(-5); // Use the abs function to compute the absolute value of a number
// z = round(3.14159); // Use the round function to round a number to the nearest integer
// z = std::ceil(3.14159); // Use the ceil function to round a number up to the nearest integer
// z = floor(3.14159); // Use the floor function to round a number down to the nearest integer
// z =std::log(10); // Use the log function to compute the natural logarithm of a number
std::cout << z;
return 0;
}