Conditional Statements – C++

Conditional Statements in C++

C++ supports the conditional statement.

Some examples of conditional statements are mentioned below;

  • Equal to: X == Y
  • Greater than: X > b
  • Greater than or equal to: X >= Y
  • Less than: X < Y
  • Less than or equal to: X <= Y
  • Not Equal to: X != Y

You can use these conditions to perform different actions for different decisions.

C++ has the following conditional statements:

Conditional Statements - C++

Conditional Statements – C++

Statements in the boy of “if”  will execute, when the given condition is true

The given condition on line 2 is true, so line#3, 4, and 5 will execute.

Statements in the boy of “else” will execute, when the given condition in the “if” part is false.

when else part execute in c++

    when else part execute in c++

 

 

 

 

 

 

 

 

 

 

Statements in the boy of “else if” will execute, when the given condition in “if” part is false and the condition in “else if”  part is true.

when else if part execute in C++
when else if part execute in C++

F

 

 

 

 

 

 

 

 

 

 

 

 

 

Exercise of If else statements (50+ Programs)

switch conditional statement is used to specify many alternative blocks of code to be executed.

how switch statement works C++

Exercise of switch statements (50+ Programs)

shamil memory table
shamil memory table

Add a Comment