-
Notifications
You must be signed in to change notification settings - Fork 0
/
conditionals.cpp
46 lines (46 loc) · 1.23 KB
/
conditionals.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
// In Flow Charts this concept is visualized pictorially under " Decision Box "
int Type1()
{
if() // if executes when condition is true and else executes when condition is false
if()
if()
if()
}
int Type2()
{
if()
else
if() // don't confuse it is similar to else if though written in new line both means same
else
if()
else
//OR
if() // block of code to be executed if condition1 is true
else if() // block of code to be executed if the condition1 is false and condition2 is true
else if()
else // here this else will work like as " default: " in " switch " case, if none of the above condition is truly satisfies directly else executes
}
loops nested()
{
if()
{
if()
{
if()
else // this can continue till .....n times
}
}
else
{
if()
{
if()
else {
if()
else
} // this can continue till ....n times
}
else{
}
}
// no bracket { } requires if only single statement is after the loop or conditionals but if more than one statement present then it should be indented within braces " { } "