If Statement And Relational Operators In C++

Understanding Decision Making Structures, If Statement and Operational Operators in C++

Posted by Zohaib Qazi on may 15, 2017

If Statement And Relational Operators In C++

After reading this post you will come to understand that what decision are making structures, what is If statement? And what are relational operators in C++. However, clear your concept by reading this post and watching our Balochi videos which is placed below along with code practice.

Decision Making Structures

Decision making structures need that the computer programmer state that one or more than one conditions to be tested by the program, alongside a statement or statements which is executed then it means the condition is determined to be true, and optionally, other statements which is executed then the condition is determined to be false.

If Statement

An if statement consists of a boolean expression followed by one or more statements. If the condition is true then the code is executed. And the result be shown on screen. However, the flow diagram is shown below

Relational Operators

All of these relational operators are used to compare the values with other values. As shown below Table. Let’s take two variables for comparing the values
A = 10
B = 20

No : Operator Description Example
1 = = Equal to (A = = B) is not true.
2 != Not Equal to (A != B) is true.
3 > Greater than (A > B) is not true.
4 < Less than (A < B) is true.
5 >= Greater than or equal to (A >= B) is not true.
6 <= Equal to (A <= B) is true.

If Statement And Relational Operators In C++ Video in Balochi

If Statement And Relational Operators In C++ code by balochprogrammer


#include < iostream >
using namespace std;
int main()
{
int a = 10;
int b = 20;
if ( a = = b){
cout << " a is Equal to b : " << endl ;
}
if ( a != b){
cout << " a is Not Equal to b : " << endl ;
}
if ( a > b){
cout << " a is Greater than b : " << endl ;
}
if ( a < b){
cout << " a is Less than b : " << endl ;
}
if ( a >= b){
cout << " a is Greater than or Equal to b : " << endl ;
}
if ( a <= b){
cout << " a is Less than or Equal to b : " << endl ;
}
return 0 ;
}