2. Control Structures in C Language
Typing Speed:19
Fasalul habeeb
fasalulhabeeb@gmail.com
www.facebook.com/Fasalul
habeeb
twitter.com/username
in.linkedin.com/in/profilenam
e
9544962714
3. Control Structures in C Language
• C language possesses such decision making
capabilities and supports the following
statements known as control or decisionmaking statements.
• if statement
switch statement
Conditional operator statement
goto statements
4. if Statement
• The if statement is a powerful decision making statement and
is used to controlthe flow of execution of statements. It is
basically a two-way decision statement and is used in
conjunction with an expression.
Syntax
if (conditional)
{
block of statements executed if conditional is true;
}
else
{
block of statements if condition false;
}
6. if-else-if statement
•
void main(void)
{
int numb;
printf("Type any Number : ");
scanf("%d", &numb);
if(numb > 0) {
printf("%d is the positive number", numb);
}
else if(numb < 0)
printf("%d is the Negative number", numb);
else printf("%d is zero",numb);
}
7. Switch Statement:
•
The switch and case statements help control
complex conditional and branching
operations.
The switch statement transfers control to a
statement within its body.
8. Example of a switch statement
• #include
main(){
int numb;
printf("Type any Number");
scanf("%d",&numb);
switch(numb %2)
{
case 0 : printf("the number %d is even ", numb);
}
}
case 1 : printf("the number %d is odd ", numb);
break;
9. break statement
•
•
•
break statement is used to exit from a loop or a switch, control passing to the first
statement beyond the loop or a switch.
Example
for(i=0;i<=10;i++)
{
if(i==5)
{
break;
}
printf(" %d",i);
}
Output:
0
1
2
3
4
10. The goto statement
• The goto is a unconditional branching statement
used to transfer control of the program from
one statement to another.
• syntax
• goto label;
• .............
• .............
• label:
• statement;
12. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
13. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550