-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUsing_operator.cpp
More file actions
70 lines (47 loc) · 990 Bytes
/
Copy pathUsing_operator.cpp
File metadata and controls
70 lines (47 loc) · 990 Bytes
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
70
#include<iostream>
using namespace std;
int main(){
//Comma Operator
int a,b,c;
//Assignment operator
a=10;
b=20;
c=30;
//Logical Operator
if(c>a and c>b){
cout<<"C is largest :"<<endl;
}
//ternary operator
int x=c%2==0?1:0;
cout<<x<<endl;
c%2==0? cout<<"Even" : cout<<"odd" ;
cout<<endl;
//Bitwise Operator
x=5;
int y=7;
cout<<"AND "<< (x&y) <<endl;
cout<<"OR "<< (x|y) <<endl;
cout<<"XOR "<< (x^y) <<endl;
//shift operator
x=x<<2;
cout<<x<<endl;//20
cout<<(y>>1)<<endl;//3
//unary operator
//address
cout<<(&x)<<endl;
//post Increment/Decrement operator
a=10;
int z=a++ ; //z=10,a=11
cout<<z<<endl;
z=++a; //a=12,z=12
cout<<z<<endl;
//compound assignment operator
a=10;
a*=3;
cout<<"A after multiply : "<<a<<endl;//30
a%=5;
cout<<"A after modulo : "<<a<<endl;//0
b=5;
b<<1;
cout<<"B after left shift " <<b<<endl; //b=10;
}