-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut06.cpp
executable file
·55 lines (50 loc) · 2.22 KB
/
tut06.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
#include <iostream>
int main() {
// arithmetic operators
int a = 5;
int b = 2;
std::cout << "Value of a: " << a << std::endl;
std::cout << "Value of b: " << b << std::endl;
std::cout << "Value of a + b: " << a+b << std::endl;
std::cout << "Value of a - b: " << a-b << std::endl;
std::cout << "Value of a * b: " << a*b << std::endl;
std::cout << "Value of a / b: " << a/b << std::endl;
std::cout << "Value of a % b: " << a%b << std::endl;
std::cout << std::endl;
// increment-decrement operators:
int x = 1;
std::cout << "Value of x (initial): " << x << std::endl;
std::cout << "Value of ++x: " << ++x << std::endl;
std::cout << "Value of --x: " << --x << std::endl;
std::cout << "Value of x++: " << x++ << std::endl;
std::cout << "Value of x--: " << x-- << std::endl;
std::cout << "Value of x (final): " << x << std::endl;
std::cout << std::endl;
// assignment operators:
int var = 0;
// logical operators:
std::cout << "Value of (0 && 0): " << (0&&0) << std::endl;
std::cout << "Value of (0 && 1): " << (0&&1) << std::endl;
std::cout << "Value of (1 && 0): " << (1&&0) << std::endl;
std::cout << "Value of (1 && 1): " << (1&&1) << std::endl;
std::cout << "Value of (0 || 0): " << (0||0) << std::endl;
std::cout << "Value of (0 || 1): " << (0||1) << std::endl;
std::cout << "Value of (1 || 0): " << (1||0) << std::endl;
std::cout << "Value of (1 || 1): " << (1||1) << std::endl;
std::cout << "Value of !0: " << (!0) << std::endl;
std::cout << "Value of !1: " << (!1) << std::endl;
std::cout << std::endl;
// relational operators:
int m = 0;
int n = 1;
std::cout << "Value of m: " << m << std::endl;
std::cout << "Value of n: " << n << std::endl;
std::cout << "Value of m == n: " << (m==n) << std::endl;
std::cout << "Value of m != n: " << (m!=n) << std::endl;
std::cout << "Value of m < n: " << (m<n) << std::endl;
std::cout << "Value of m > n: " << (m>n) << std::endl;
std::cout << "Value of m <= n: " << (m<=n) << std::endl;
std::cout << "Value of m >= n: " << (m>=n) << std::endl;
std::cout << std::endl;
return 0;
}