forked from prasannna639aditya/Coding-Repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintro_cp_live_code.cpp
130 lines (107 loc) · 3.39 KB
/
intro_cp_live_code.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include<bits/stdc++.h>
using namespace std;
int main(){
// cout << "Hello world";
// cout << endl;
// cout << "Shaun";
// integer container : int
// int variable1; // declared the variable
// variable1 = 7; // assigned it the value 7
// cout << variable1;
// cout << endl;
// cout << variable1 << endl; // this is same as the above two line
// int variable2 = 7; // this is same as above
// cout << variable2 << endl;
// decimal container : float
// float variable3 = 2.7;
// cout << variable3 << endl;
// character 'a', 'b' .. ','. '?', '['
// character container : char
// char variable4 = 'c';
// cout << variable4 << endl;
// boolean : true or false
// true : 1 (keyword in c++)
// false : 0 (keyword in c++)
// boolean container : bool
// bool variable5 = false;
// cout << variable5 << endl;
// int roll_no = 0;
// cin >> roll_no; // taking input
// cout << roll_no << endl; // value of the roll_no
// int age = 0;
// cin >> age;
// cout << age << endl;
// char initial;
// cin >> initial;
// cout << initial << endl;
// float percentage;
// cin >> percentage;
// cout << percentage << endl;
// int num1 = 10;
// int num2 = 20;
// int sum1 = num1 + num2;
// cout << sum1 << endl;
// float num3 = 1.2;
// float num4 = 1.1;
// float diff1 = num3 - num4;
// cout << diff1 << endl;
// int num5 = 10;
// int num6 = 3;
// int mul1 = num5 * num6;
// cout << mul1 << endl;
// int num7 = 10;
// int num8 = 5;
// int div1 = num7 / num8;
// cout << div1 << endl;
// int div2 = num8 / num7; // integer division (ignores the decimal values)
// int div2 = 0;
// float div3 = num8 / num7;
// float div3 = 0;
// cout << div3 << endl;
// float num9 = 10.0;
// float num10 = 5.0;
// float div4 = num10 / num9; // floating division
// cout << div4 << endl;
// Logical operators
// bool great = (2 > 3); // false
// cout << great << endl;
// bool greatEq = (2 >= 3); // false
// cout << greatEq << endl;
// bool less = (2 < 3); // true
// cout << less << endl;
// bool lessEq = (2 <= 3); // true
// cout << lessEq << endl;
// bool equal = (2 == 3); // note that there are two == signs
// cout << equal << endl;
// bool notequal = (2 != 3); // true
// cout << notequal << endl;
// if number is greater than 3 and less than 5
// int num;
// cin >> num;
// bool greaterthanthree = (num > 3); // true
// bool lessthanfive = (num < 5); // true
// // the and operator - &&
// // bool1 && bool2
// bool finalCheck = greaterthanthree && lessthanfive;
// cout << finalCheck << endl;
// if number is less than 3 OR greater than 5
// int num;
// cin >> num;
// bool lessthanthree = (num < 3); // false
// bool greaterthanfive = (num > 5); // false
// // or operator - ||
// // either bool1 or bool2 is true
// bool finalCheck = lessthanthree || greaterthanfive;
// cout << finalCheck << endl;
/* Problem 1 from PS */
// int a;
// cin >> a;
// int b;
// cin >> b;
// int c;
// cin >> c;
// int d;
// cin >> d;
// int sum = a + b + c + d
// cout << sum << endl;
}