-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_conditionals.cpp
More file actions
executable file
·63 lines (54 loc) · 1.71 KB
/
Copy path10_conditionals.cpp
File metadata and controls
executable file
·63 lines (54 loc) · 1.71 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
#include <iostream>
using namespace std;
int main()
{
int rating;
cout << "Enter your rating you wanna give to this course between 1 to 5 : ";
cin >> rating;
/*
so the syntax is :
if (condition)
{
your code
}
OR it can be like
if (condition 1)
{
your code
}
else if (condition 2)
{
your code
}
OR it can be also like
if (condition 1)
{
your code
}
else if (condition 2)
{
your code
}
else
{
your code which will be executed by default when all the above conditions will get false
}
*/
if (rating == 5) // "==" is used to check for equality and just "=" is used for assgining
{
puts("Thanks for your positive feedback !!"); // condition 1
}
else if (rating == 4)
{
puts("Thanks for your positive feedback !! We will improve ourselves"); // condition 2
}
else
{
puts("We are very sorry !! How can we improve ? "); // the default part
}
// This feels lengthy to you ?
// no problem C/C++ got you covered you back let's see
rating > 0 ? puts("Thanks for feedback ") : puts("Are we that bad ? "); // we have done the if else part using "ternary operator"
// condition ? "True Part " : "False Part";
return 0;
}