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

Loops in C Programming 1

Uploaded by

j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Loops in C Programming 1

Uploaded by

j
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

LOOPS in C++

PROGRAMMING
https://www.youtube.com/watch?v=wxds6MAtUQ0
The Loop (iteration/repetition)
Statements allow a set of instructions to
be performed repeatedly until a certain
condition is fulfilled.
PARTS OF A LOOP
1. Initialization Expression (s) initialize (s) the loop variables in the beginning
of the loop.
2. Test Expression decides whether the loop will be executed (if test expression
is true)or not (if test expression is false ).
3. Update Expression (s)update (s) the values of the loop variables after every
iteration of the loop.
4. The body of the loop contains statements to be executed repeatedly.
SYNTAX:
LOOP TYPES:
C++ programming language provides types of loop to
handle looping requirements.
for loop
The “for loop” is used to execute a statement or set of statements
repeatedly for a specific number of times.
This loop is also known as counter loop.
Example of for loop: Find 5 numbers using for loop.
2. Sum up all of the values starting from the user input and going until
the sum is greater than 90, again outputting results as you go.
3. Create a C++ program that will display greetings to your classmates
15 times during quarantine period.
Answer the following:
1. How important are loop statements in C++ program?
2. What is a for loop statement? How does it works inside
the C++ program?
Assignment:
1. What is while loop?
2. Give the flowchart and syntax of while loop.
3. Write 2 sample programs using while loop.

You might also like