-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperators & operands.cpp
57 lines (43 loc) · 1.12 KB
/
operators & operands.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
#include <iostream>
using std::cout ;
int main(){
5 + 5 ; // + is operator 5 is operand
int num = 4 << 2 ; // 4 * 2**2
// 16
num = 4 >> 2 ; // 4 / 2**2
// 1
num = 1&0 ; //bitwise and
// 0
num = 1&1 ;
// 1
num = 1|0 ; //bitwise or
// 1
num = 1^0 ; //bitwise xor
// 1
double x,y ;
y = 50 ;
x = y = 100 ;
//x=100
//y= 50
(x=y) = 200 ;
cout << x <<" : " << y;
//x=200
//y=100
int value = 5 ;
cout << std::endl ;
cout << value++ << std::endl; // -> 5
cout << value << std::endl ; // 6
value = 5 ;
cout << ++value << std::endl ; // -> 6
cout << value++ << std::endl ; // -> 6
cout << value++ << std::endl ; // -> 7
cout << ++value << std::endl ; // -> 9
cout << (value = value-1) << std::endl ; // 8
cout << value-1 << std::endl ; // 7
cout << value << std::endl ; // 8
cout << (value*=2) << std::endl ; // 16
cout << (value/=2) << std::endl ; // 8
cout << (value=value*2) << std::endl ; // 16
cout << (value=value/2) << std::endl ; // 8
cout << value << std::endl ; // 8
}