-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6-conditional_example.cpp
69 lines (61 loc) · 1.22 KB
/
6-conditional_example.cpp
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
67
68
69
#include <iostream>
int main()
{
int a = 5;
int b = 7;
// Equality check (==)
if (a == b)
{
std::cout << "a is equal to b" << std::endl;
}
else
{
std::cout << "a is not equal to b" << std::endl;
}
// Inequality check (!=)
if (a != b)
{
std::cout << "a is not equal to b" << std::endl;
}
else
{
std::cout << "a is equal to b" << std::endl;
}
// Greater than (>)
if (a > b)
{
std::cout << "a is greater than b" << std::endl;
}
else
{
std::cout << "a is not greater than b" << std::endl;
}
// Greater than or equal to (>=)
if (a >= b)
{
std::cout << "a is greater than or equal to b" << std::endl;
}
else
{
std::cout << "a is less than b" << std::endl;
}
// Less than (<)
if (a < b)
{
std::cout << "a is less than b" << std::endl;
}
else
{
std::cout << "a is not less than b" << std::endl;
}
// Less than or equal to (<=)
if (a <= b)
{
std::cout << "a is less than or equal to b" << std::endl;
}
else
{
std::cout << "a is greater than b" << std::endl;
}
return 0;
}