Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
28 views9 pages

C++ Control Statements Flowcharts

The document provides an overview of control statements in C++, which dictate the flow of execution in programs. It categorizes them into selection statements (if, if-else, switch), iteration statements (for, while, do-while), and jump statements (break, continue, goto, return), each with syntax and example programs. Understanding these control statements is essential for writing efficient C++ code.

Uploaded by

deepika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views9 pages

C++ Control Statements Flowcharts

The document provides an overview of control statements in C++, which dictate the flow of execution in programs. It categorizes them into selection statements (if, if-else, switch), iteration statements (for, while, do-while), and jump statements (break, continue, goto, return), each with syntax and example programs. Understanding these control statements is essential for writing efficient C++ code.

Uploaded by

deepika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

C++ Control

Statements
Flowcharts, Syntax & Programs for Each Type
Introduction

• Control statements in C++ define the flow of execution.

• Types:
• - Selection Statements (if, if-else, switch)
• - Iteration Statements (for, while, do-while)
• - Jump Statements (break, continue, goto, return)
Selection: If-Else Statement

• Used for decision-making.

• **Syntax:**
• if (condition) {
• // Code when true
• } else {
• // Code when false
• }

• **Example Program:**
• int num = 10;
• if (num > 0) {
• cout << 'Positive';
• } else {
• cout << 'Negative';
• }
Selection: Switch Statement

• Used for multiple conditions.

• **Syntax:**
• switch (expression) {
• case value1: // Code
• break;
• default: // Code
• }

• **Example Program:**
• int day = 2;
• switch (day) {
• case 1: cout << 'Monday'; break;
• case 2: cout << 'Tuesday'; break;
• default: cout << 'Other Day';
• }
Iteration: For Loop

• Used for repeating a block of code.

• **Syntax:**
• for (init; condition; update) {
• // Code
•}

• **Example Program:**
• for (int i = 0; i < 5; i++) {
• cout << i;
•}
Iteration: While Loop

• Executes while condition is true.

• **Syntax:**
• while (condition) {
• // Code
• }

• **Example Program:**
• int i = 0;
• while (i < 5) {
• cout << i;
• i++;
• }
Iteration: Do-While Loop

• Executes at least once before checking condition.

• **Syntax:**
• do {
• // Code
• } while (condition);

• **Example Program:**
• int i = 0;
• do {
• cout << i;
• i++;
• } while (i < 5);
Jump Statements

• Alter the flow of execution.

• - break: Exits a loop or switch


• - continue: Skips an iteration
• - goto: Jumps to a labeled statement
• - return: Exits a function

• **Example:**
• for (int i = 0; i < 5; i++) {
• if (i == 3) break;
• cout << i;
•}
Conclusion

• C++ Control Statements help manage execution flow.

• - Selection: if-else, switch


• - Iteration: for, while, do-while
• - Jump: break, continue, goto, return

• Mastering these helps in writing efficient code!

You might also like