0% found this document useful (0 votes)
23 views5 pages

Lab Report Title

The document discusses looping structures in C++ including while, do-while, and for loops. It provides examples of how to write each type of loop and explains their syntax. Additionally, it covers the continue and break statements, how to write a compound interest calculation, and provides the steps taken in the lab to practice examples of each looping structure and statement.

Uploaded by

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

Lab Report Title

The document discusses looping structures in C++ including while, do-while, and for loops. It provides examples of how to write each type of loop and explains their syntax. Additionally, it covers the continue and break statements, how to write a compound interest calculation, and provides the steps taken in the lab to practice examples of each looping structure and statement.

Uploaded by

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

LAB REPORT

Title
Looping structure, compound interest statement structure,continue and break statement structure in C++.
Objective
To learn and understand th
Appratus
• Computer with all its components
• Dev C++ Software.
Theory
Loops in C++
A loop statement allows us to execute a statement or group of statements multiple times. There may be a
situation, when you need to execute a block of code several number of times. In general, statements are
executed sequentially: The first statement in a function is executed first, followed by the second, and so on.
Loops Types and discription:
Following are the types of loop that most commenly used in c++ programming.
• While loop
• Do-While loop
• For loop
Now we discuss loop one by one.
While loop
Repeats a statement or group of statements while a given condition is true. It tests the condition before
executing the loop body. Its syntax and example is given in procedure. The syntax of a while loop is:
while
(testExpression)
{
// codes }
Do-While loop
The do...while loop is a variant of the while loop with one important difference. The body of do...while loop is
executed once before the test expression is checked. It example is given in procedure.
The syntax of do..while loop is:
do {
// codes;
}
while (testExpression);
For-loop
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a
specific number of times. The syntax of For loop is following. It example is given in procedure.
for ( init; condition; increment )
{
statement(s);}
Continue and Break Statement in C++
In C++, there are two statements break; and continue; specifically to alter the normal flow of a
program.Sometimes, it is desirable to skip the execution of a loop for a certain test condition or terminate it
immediately without checking the condition.For example: You want to loop through data of all aged people
except people aged 65. Or, you want to find the first person aged 20.In scenarios like these, continue; or a
break; statement is used.
C++ break statement.
The break; statement terminates a loop (for, while and do..while loop) and a switch statement immediately
when it appears. Its syntax is given following. Its example is given in procedure
break;
Continue Statement in C++
It is sometimes necessary to skip a certain test condition within a loop. In such case, continue; statement is used
in C++ programming. Its example is given in procedure.Its sntax is given as following.
continue;
Compound Interest Statement in C++
Compound intrest statemnt also follow the structure of loop statement. With the help of this statemnt we can
calculate the interest on deposited amount of nth year.
A=p(1+r)^n
Where p is the principle amount, r is the amount interest rate,n are number of year and a is net amount after nth
year.
Procedure
The methodology of this lab is following.
Step 01
In first step we open the dev c++ software from start manue of computer. Then click on new and then click on
new source.
Step 02
First we write example of while loop statement. It example is given as
Step 03
In this step we write example of do-while statement. It is given as follow

Step 04
In this step we write example of for statement. It is given as follow.
Step o5
In this statement we writ example of compound interest statement. It is given as

Step 06
In this step we write example of continue statement. It is given as follow
Step 07
In this step we write example of break statement. It is given as follow.

Learning Outcomes
In this lab we learn about looping structure in C++. We also learn different types of loop and their syntax. After
that we also practice the example of different types of loop. We also learn about compound interest statement
and use this to calculate the amount of interest by given formula. We also learn about continue and break
statement and write their example.

You might also like