A
statement that is used to control the flow of execution in a program is called
control structure. It combines instruction into logical unit. Logical unit has
one entry point and one exit point.
Types of control structures
1. Sequence
2. Selection
3. Repetition
4. Function call
1.
Sequence: Statements are executed in a specified order. No statement is
skipped and no statement is executed more than once.
Flow
Chart:
For Example
#include<stdio.h>
void
main()
int a;
{
int a=5;
int a=5;
printf(“Square
of a = %d”,a);
}
}
2.
Selection:
ItIt
selects a statement to execute on the basis of condition. Statement is executed
when the condition is true and ignored when it is false e.g if, if else, switch
structures.
For Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
int y;
clrscr();
printf("Enter a year:");
scanf("%d",&y);
if (y % 4==0)
printf("%d is a leap
year.",y);
else
printf("%d is not a leap
year.".y)
getch();
}
3.
Repetition: In this
structure the statements are executed more than one time. It is also known as
iteration or loop e.g while loop, for loop do-while loops etc.
Flow Chart:
For Example:
#include<stdio.h>
#include<conio.h>
void
main()
{
int a=1;
clrscr();
while(a<=5)
{
printf(“I
Love Pakistan\n”);
a++;
}//end of while
}//end of main
4. Function call: It is
used to invite or call a piece of code or statement. In this case control jumps
from main program to that piece of code and then returns back to main program.
Flow
Chart:




waoooooooooooo this i am looking for.thank u.
ReplyDeletemention not :)
ReplyDelete