Control Statements in C++

πŸ“˜ C++ πŸ‘ 32 views πŸ“… Dec 22, 2025
⏱ Estimated reading time: 1 min

Control statements determine the flow of execution of a C++ program.


Types of Control Statements

C++ control statements are broadly divided into:

  1. Selection Statements

  2. Iteration Statements

  3. Jump Statements


1. Selection Statements

Used to make decisions based on conditions.

(a) if Statement

if (condition) { // statements }

(b) if–else Statement

if (condition) { // true block } else { // false block }

(c) else–if Ladder

if (condition1) { // block 1 } else if (condition2) { // block 2 } else { // default block }

(d) switch Statement

switch (expression) { case 1: // statements break; case 2: // statements break; default: // statements }

2. Iteration Statements

Used to repeat a block of code.

(a) for Loop

for (int i = 0; i < 5; i++) { cout << i>

(b) while Loop

int i = 0; while (i < 5) { cout << i>

(c) do–while Loop

int i = 0; do { cout << i>while (i < 5);

3. Jump Statements

Used to transfer control.

StatementDescription
breakTerminates a loop or switch
continueSkips current iteration
gotoTransfers control unconditionally
returnExits from a function

Example:

break; continue; return 0;

Key Points

  • Control statements manage program flow

  • Selection statements make decisions

  • Iteration statements repeat tasks

  • Jump statements alter execution flow


Conclusion

Control statements are essential in C++ for implementing logic, conditions, and repetitive tasks in programs.


πŸ”’ Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes