-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLecture5.cpp
More file actions
114 lines (85 loc) · 3.13 KB
/
Copy pathLecture5.cpp
File metadata and controls
114 lines (85 loc) · 3.13 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include<iostream>
using namespace std;
int main(){
// ::::::::::::::::Bitwise operators::::::::::::::::
// int a = 4;
// int b = 6;
// cout<<"a&b "<<(a&b)<<endl; // And
// cout<<"a|b "<<(a|b)<<endl; // Or
// cout<<"~a "<<(~a)<<endl; // Not
// cout<<"a^b "<<(a^b)<<endl; // Xor
// // ::::::::::::::::::Right shift operator::::::::::::::::::
// cout<< (17>>1) <<endl; // 17/(2)
// cout<< (17>>2) <<endl; // 17/(2*2)
// // ::::::::::::::::Left shift operator::::::::::::::::::::
// cout<< (19<<1) <<endl; // 19*(2)
// cout<< (19<<2) <<endl; // 19*(2*2)
// // If we shift left or right a big number then the number would become negative also.
// // -------::::::::::increament operators ::::::::::--------
// int sum;
// int a = 5;
// int i = 6;
// sum = a + (i++); // post increament => pehle i=6 se statement print kro then i=7 kro.
// cout<<sum<<endl;
// int sum1; a = 5; i = 6;
// sum1 = a + (++i); // pre increament => pehle i=7 kro then i=7 se statement print kro.
// cout<<sum1<<endl;
// // same for decreament operator also
// // :::::::::::::::FOR LOOP:::::::::::::::::
// // for(initialization , condition , updation){
// // src code
// // }
// int n;
// cin>>n;
// for(int j=1; j<=n; j++){ // Single initialization,condition,updation.
// cout<<j<<endl;
// }
// int n;
// cin>>n;
// for(int a=0,b=1; a>=0 && b>=1; a--,b--){ // Multiple initialization,condition,updation.
// cout<<a<<" "<<b<<endl;
// }
// // EG (1):-
// int n;
// cout<<"enter the vakue of n :";
// cin>>n;
// int sum = 0;
// for(int i=1; i<=n; i++){
// // sum = sum + i;
// sum += i;
// }
// cout<<sum<<endl;
// // FIBONACCI SERIES
// int n = 10;
// int a = 0;
// int b = 1;
// cout<<a<<" "<<b<<" ";
// for(int i = 0; i<=n; i++){
// int nextnum = a+b;
// cout<<nextnum<<" ";
// a = b;
// b = nextnum;
// }
// return 0;
// // (PRIME NUMBER OR NOT) USING - BREAK:-
// int n;
// cin>>n;
// for(int i = 2; i<n; i++){
// if(n%i==0){
// cout<<"Not a prime number"<<endl;
// break; // it exits the loop.
// }
// else{
// cout<<"prime number"<<endl;
// break;
// }
// }
// // USING THE CONTINUE:-
// for(int i=0; i<=5; i++){
// cout<<"hey"<<endl;
// cout<<"hyy"<<endl;
// continue; // it do not exit the loop but it skips the next iteration
// cout<<"reply to krr"<<endl; // skips
// }
// return 0;
// }