C++ If

C++ Control Statement C++ control statement or decision-making statement is used to control the flow of program statement according to condition applied.   C++ if Control Statement An if control statement in C++ is used to control the flow of program statement on behalf of condition applied. When if condition returns true boolean value, then statement within if block will be …

Read moreC++ If

C++ Nested if

C++ nested if Control Statement Nested if control statement refers to if condition within if condition. C++ compiler checks nested if control statement when its parent if condition returns true, then the program is executed according to nested if condition. Syntax



← Prev Next→

C++ if-else

C++ if else Control Statement if else control statement in C++ is used to control the program flow in a two-way direction. When condition returns a true value, then the program executes if condition block otherwise program executes else block. Syntax:

C++ if else Example


← Prev Next→

C++ If-else-if

C++ if.. else if Control Statement if.. else if control statement is an if statement used with an optional else if control statement to check multiple conditions. In this control statement, when any one of condition returns true, then none of the other else if or else will be executed. Syntax

C++ if..else if Example


← Prev Next→

C++ Switch

C++ switch Control Statement The switch control statement allows checking the variable for equality against a list of values. The switch statement checks an integer, char or enumerated type in its condition expression. It does not take any floating variable in its condition expression. Syntax

C++ switch Example


← Prev Next→

C++ Break

C++ break Statement The break statement is used to alter the normal flow of a program. The break statement terminates a loop (for, while and do..while) and switch statement instantly where it applied. When a break statement is applied inside the nested loop, it only affects (breaks) the inner loop. Syntax

C++ break Example


← Prev Next→

C++ Continue

C++ continue Statement The continue statement forces to iterate the loop instantly without executing the next statement of the loop. Sometimes it is required to skip certain test condition within the loop, in such case continue statement is applied. When continue statement is applied inside the nested loop, it only affects (iterate) the inner loop. Syntax



← Prev …

Read moreC++ Continue

C++ Goto

C++ goto Statement A goto statement is used to jump the flow of a sequence of program execution. It transfers the control to some other part of the program. The goto uses an identifier that encountered the control of program jumps to an identifier. Syntax

  Example This program calculates the average of numbers entered by the user. …

Read moreC++ Goto

C++ For loop

C++ loop Statement A loop statement allows us to repeat the execution of a statement or group of statements multiple times. The statement(s) repeat execution within loop until the condition of loop became false. There are three types of loops in C++ programming language: for loop while loop do…while loop     C++ for Loop Statement The for loop …

Read moreC++ For loop

C++ While loop

C++ while Loop Statement The while loop is an iterative control statement. A while loop repeatedly executes loop’s statement(s) several times as a given condition is true. Execution of loop is terminated when the condition of while loop becomes false and execute code after the loop. Syntax

  Working Process Of While Loop While loop first checks the condition applied. If the …

Read moreC++ While loop