0% found this document useful (0 votes)
50 views

Control Structure in C

The document discusses different types of control structures in C++ including sequential, selection, and conditional structures. It describes the if, if-else, if-else-if, switch-case statements as well as for, while, and do-while loop structures. Sample problems and programs are provided as examples to demonstrate how to use each control structure.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Control Structure in C

The document discusses different types of control structures in C++ including sequential, selection, and conditional structures. It describes the if, if-else, if-else-if, switch-case statements as well as for, while, and do-while loop structures. Sample problems and programs are provided as examples to demonstrate how to use each control structure.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Control Structure in C++

>Three different types of control structures


1. Sequential Structure
2. Selection Control Structure
3. Conditional Structure

Single alternative

● The "If" statement


– if condition with compound statement

● If-else condition
● if-else-if condition

>Program (sample prob 5-1 using if-else statement)


>Program (sample prob 5-1 using if-else statement)

> Sample Problem 5-2


● Program (Sample Problem 5-2)

> Sample Problem 5-3


● Program (Sample Problem 5-3)

3. The switch-case statement


● Break

> Sample Problem 5-4: Using switch-case statement


● Program (Sample Problem 5-4)

4. Loops/Repetition Statements
● These are two types of repetition statements:
– pretest repetition statement
– posttest repetition statement

5. For Statement

> Sample Problem 5-5: Using for statement


● Program (Sample Problem 5-5)

> Sample Problem 5-6: This program displays the string “Hello World” ten times.
● Program (Sample Problem 5-6)

6. while Statement
> Sample Problem 5-7: Using while statement
● Program (Sample Problem 5-7)

> Sample Problem 5-8: Using while statement


● Program (Sample problema 5-8)

7. The do-while loop


> Sample Problem 5-9: Using do-while
● Program (Sample Problem 5-9)

> Sample Problem 5-10: Using “do-while” and “if” statement


● Program (Sample Problem 5-10)

~Page 24

You might also like