-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path15-math.cpp
More file actions
71 lines (48 loc) · 1.45 KB
/
Copy path15-math.cpp
File metadata and controls
71 lines (48 loc) · 1.45 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// C++ has fuctions that allow you to perform mathematical tasks on numbers.
// MAX and MIN function
// the max(x,y) function can be used to find the highest value of x and y:
// min(x,y) gives the lowest value.
// to use these functions we first require the math header
//Example
#include <iostream>
#include <cmath>
using namespace std;
void main() {
cout << max(5,10);
cout << min(5,10);
}
/*
some examples of math functions are given below:
abs(x) - returns absolute value of x
cos(x) - returns cosine of x
sin(x) - returns sin of x
tan(x) - returns tan of x
cbrt(x) - returns cube root of x
ceil(x) - rounds up x to nearest integer
exp(x) - returns exponential of x
floor(x) - rounds x down to nearest integer
*/
//Booleans
//Booleans simply return True or False
//Example
#include<iostream>
using namespace std;
void main() {
bool a = true;
bool b = false;
cout << a;
cout << b;
}
// boolean operators
// using logical operators will also return true or false values.
//Example
#include <iostream>
using namespace std;
void main() {
int x = 10;
int y = 9;
cout << (x > y); // this will return the value True. Because 10 is greater than 9.
cout << (x < y); // this will return false because 10 is not less than 9.
cout << (x == 10); // this will return true because previously x was declared as 10.
cout << (10 == 15); // returns false because 10 is not equal to 15.
}