1if (condition) {
2 // block of code to be executed if the condition is true
3}
1if (condition) {
2 // block of code if condition is true
3}
4else {
5 // block of code if condition is false
6}
1 if( a == 10 ) {
2 cout << "Value of a is 10" << endl;
3 } else if( a == 20 ) {
4 // if else if condition is true
5 cout << "Value of a is 20" << endl;
6 }
1#include<iostream>
2using namespace std;
3
4int main()
5{
6 int grade;
7
8 cin >> grade;
9
10 if( grade >= 60 )
11 cout << "You Pass!" << endl;
12 else
13 cout << "You Fail..." << endl;
14
15 return 0;
16}
17
1if (condition)
2{
3 // block of code
4}
5else if (condition)
6{
7 // block of code
8}
9else {
10 // block of code
11}