0% found this document useful (0 votes)
20 views14 pages

Control Structurer Presentation

The document discusses different types of control structures in C++ including sequence, selection, and repetition structures. Sequence structure executes statements in the order specified. Selection structure selects statements to execute based on a condition. Repetition structure repeatedly executes statements using loops like for, while, and do-while.
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)
20 views14 pages

Control Structurer Presentation

The document discusses different types of control structures in C++ including sequence, selection, and repetition structures. Sequence structure executes statements in the order specified. Selection structure selects statements to execute based on a condition. Repetition structure repeatedly executes statements using loops like for, while, and do-while.
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

Control Structure

Types of Control Structure


Control structure
• A statement used to control the flow of
execution in a program is called control
structure.
Types of Control Structure
• 1 . Sequence structure
• 2 . Selection structure
• 3 . Repetition structure
Sequence structure
• In sequence structure, the statements are
executed in the same order in which they are
specified in program. The control flow from
one statement to other in a logical sequence.
All statement are executed exactly once. It
means that no statement is skipped and no
statement is executed more then once.
Sequence structure
Sequence structure
Write a program that adds two number and shows the sum.
#include <iostream.h>
#include <conio.h>
Void main()
{
int var1,var2,sum;
var1=30;
var2=20;
sum =var1+var2;
cout<<sum;
getch();
Selection Structure
• A selection structure selects a statement or
set of statements to execute on the basis of a
condition. In this structure, statement or set
of statements is executed when a particular
condition is true and ignored when the
condition is false.
Selection Structure
• There are different types selection structure in
c++.
• These are if , if……else, and switch.
Selection Structure
Selection Structure
Write a program that inputs marks and display “pass” if the
marks are 40 or more.
#include <iostream.h>
#include <conio.h>
Void main()
{
int marks;
cout<<“Enter your marks”;
cin>>marks;
If (marks>=40)
cout<<“pass”;
getch();
Repetition Structure
• A repetition structure executes a statement or
set of statements repeatedly. It is also known
as iteration structure or loop.
Repetition Structure
• There are different types of repetition
structure in c++.
• These are while, do-while and for.
Repetition Structure
Repetition Structure
Write a program that displays counting 1 to 5 using for loop.
#include <iostream.h>
#include <conio.h>
Void main()
{
int n;
for(n=1;n<=5;n++)
cout<<n;
getch();

You might also like