-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.condtionals.cpp
160 lines (137 loc) · 3.12 KB
/
2.condtionals.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <iostream>
using namespace std;
// conditional statements in c++ used for defing the condition in the code
// like if the 1 is smaller then 2
// if -- for sigle condition
// else if condition does not meet the else execute
// else if -- for multiple condition
//! example of if statem
// if the n == 10 then print "n is 10"
void print()
{
int n = 10;
if (n == 10)
{
cout << "n is 10" << endl;
}
}
//! example of if else statement
// if the n == 10 then print "n is 10" else print "n is not 10"
void print2()
{
int n = 10;
if (n == 10)
{
cout << "n is 10" << endl;
}
else
{
cout << "n is not 10" << endl;
}
}
//! example of if else if statement
// if the n == 10 then print "n is 10" else if n == 20 then print "n is 20" else print "n is not 10 or 20"
void print3()
{
int n = 10;
if (n == 10)
{
cout << "n is 10" << endl;
}
else if (n == 20)
{
cout << "n is 20" << endl;
}
else
{
cout << "n is not 10 or 20" << endl;
}
}
int main()
{
// sins
// > greter then
// <less then
// >= greter then equal to
// <= less then equal to
// conditional statements
// if
// else
// programming problem
// wap that takes input as age and print you are
// and adult or not
// int age;
// cin >> age;
// if (age >= 18)
// {
// cout << "you are an adult";
// }
// else{
// cout<<"you are not an adult";
// }
// problem:2 get marks from the use and
// print grade according the marks
// int marks;
// cin >> marks;
// if (marks < 25)
// {
// cout << "Grade: F" << endl;
// }
// else if (marks >= 25 && marks <= 44)
// {
// cout << "Grade: E" << endl;
// }
// else if (marks >= 45 && marks <= 49)
// {
// cout << "Grade: D" << endl;
// }
// else if (marks >= 50 && marks <= 59)
// {
// cout << "Grade: C" << endl;
// }
// else if (marks >= 60 && marks <= 69)
// {
// cout << "Grade: B" << endl;
// }
// else if (marks >= 70)
// {
// cout << "Grade: A" << endl;
// }
// else
// {
// cout << "Invalid marks entered." << endl;
// }
// use of && for checking multiple conditon
// (condition 1 && condition 2)
/*
take the age from the user and then decide accourding
1. if age < 18
print(not eligible for the job)
2. if age >= gether then equal to 18 or <= less then eual to 54
print(eligible for the job)
3.if age >= 55 and >= 57
print(aligible for job nut retirment soon)
if age >57
print (retirement soon)
*/
// for this quation we use nested if else statements
// int age;
// cin >> age;
// if (age < 18)
// {
// cout << "not eligible for the job";
// }
// else if (age <= 57)
// {
// cout << "eligible for the job";
// if (age <= 57)
// {
// cout << "retirment soon";
// }
// }
// else
// {
// cout << "retirment time ";
// }
return 0;
}