-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSession2.cpp
More file actions
86 lines (60 loc) · 1.37 KB
/
Session2.cpp
File metadata and controls
86 lines (60 loc) · 1.37 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
79
80
81
82
83
84
85
86
#include<iostream>
using namespace std;
// main is executed by OS
// main is a function or we can say it a main thread for our process
int main(){
cout<<"Hello";
// a is the name of storage container
// we also call it as a variable
// int is the data type or the type of storage container
// 10 is data or value or literal
int a = 10;
int b = 20;
// Data Operations
int c = a+b;
cout<<"c is:"<<c<<"\n";
cout<<"is a less than b ? "<<(a<b)<<"\n";
int x = 11;
x++;
++x;
x--;
--x;
x++;
// x is 12
// int y = x++; // value copy
int y = ++x;
cout<<"y is: "<<y<<"\n";
cout<<"x is: "<<x<<"\n";
cout<<"Result:"<<((x>=y) && (x>=a))<<"\n";
int p = 12; // 1 1 0 0
int q = 8; // 1 0 0 0
int r = p & q; // 1 0 0 0
int s = p ^ q; // 0 1 0 0
cout<<"r is: "<<r<<"\n";
cout<<"s is: "<<s<<"\n";
int t = q >> 2; // 1 0 0 0 >> 2 0 0 1 0 -> 2
int u = q << 2; // 1 0 0 0 << 2 1 0 0 0 0 0 -> 32
int v = u >> 2;
cout<<"t is: "<<t<<"\n";
cout<<"u is: "<<u<<"\n";
cout<<"v is: "<<v<<"\n";
int w = (10>2) ? 5 : 10;
cout<<"w is: "<<w<<"\n";
/*
Arithmetic Operators
+, -, *, /, %
Relational Operators
>, <, >=, <=, ==, !=
Increment & Decrement
++ and --
Bitwise Operators
& | ^
Logical Operators
&& || !
Shift Operators
>> <<
Ternary Operator
? :
*/
return 0; // Ack by main to OS. And Ack is always in the end !!
}