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
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
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;
}
if statement
•

Example

•
•
•
•
•
•
•
•
•
•
•
•
•

main()
{
int no1,mod;
printf("Enter a numbern");
scanf("%d",&no1);
mod=no1%2;
if(mod==0)
{
printf("the number is evenn");
}
else
{
printf("the number is oddn");
}

•

}
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);
}
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.
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;
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
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;
THE END
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
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

Control structure in c

  • 2.
    Control Structures inC 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 inC 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 • Theif 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; }
  • 5.
    if statement • Example • • • • • • • • • • • • • main() { int no1,mod; printf("Entera numbern"); scanf("%d",&no1); mod=no1%2; if(mod==0) { printf("the number is evenn"); } else { printf("the number is oddn"); } • }
  • 6.
    if-else-if statement • void main(void) { intnumb; 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 switchand case statements help control complex conditional and branching operations. The switch statement transfers control to a statement within its body.
  • 8.
    Example of aswitch 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 statementis 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;
  • 11.
  • 12.
    If this presentationhelped 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