-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoperators.cpp
More file actions
78 lines (60 loc) · 1.65 KB
/
operators.cpp
File metadata and controls
78 lines (60 loc) · 1.65 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
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
using namespace std;
int main ()
{
//Arithmetic operators
// int x=10, y=3;
// cout<<"addition:"<<x+y<<endl;
// cout<<"subtraction:"<<x-y<<endl;
// cout<<"multiplication:"<<x*y<<endl;
// cout<<"division:"<<x/y<<endl;
// cout<<"Modulo:"<<x%y<<endl;
// cout<<"addition:"<<x+y<<endl;
// post-increment and pre-increment
// float x=10.3222;
// int y;
// y=++x;
// cout<<x<<endl<<y<<endl;
// y=x++;
// cout<<x<<endl<<y<<endl;
// Relational Operators
// int x=3, y=6;
// cout<<"x<y:"<<(x+2<y+1)<<endl;
// cout<<"x>y:"<<(x>y)<<endl;
// cout<<"x<=y:"<<(x<=y)<<endl;
// cout<<"x>=y:"<<(x>=y)<<endl;
// cout<<"x==y:"<<(x==y)<<endl;
// cout<<"x>=y:"<<(x>=y)<<endl;
// cout<<"x!=y:"<<(x!=y)<<endl;
// logical operator
// int x=5, y=10;
// if ((x>5)&&(y<15))
// {
// cout<<"x+y:"<<(x+y)<<endl;
// }
// else if((x<=5)||(y>15))
// {
// cout<<"x-y:"<<(x-y)<<endl;
// }
// else
// {
// cout<<"!x:"<<!x<<endl;
// }
//Bitwise operator
// int x=26, y=9;
// cout<<"x&y:"<<(x&y)<<endl;
// cout<<"x|y:"<<(x|y)<<endl;
// cout<<"x^y:"<<(x^y)<<endl;
// cout<<"x<<1:"<<(x<<1)<<endl;
// cout<<"x>>1:"<<(x>>1)<<endl;
// cout<<"~x:"<<(~x)<<endl;
// Miscellaneous operators
float x= 6.78;
cout<<(int)x<<endl;
cout<<x<<endl;
//conditional operators
int a =3, b=12;
cout<<"Maximum is: "<<((a>b)?(a+2):(b-5))<<endl;
cout<<sizeof(a);
return 0;
}