Control structure in c

1,508 views

Published on

Control structure in c

Published in: Education, Business, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,508
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
64
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Control structure in c

  1. 1. 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
  2. 2. 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
  3. 3. 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; }
  4. 4. 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"); } • }
  5. 5. 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); }
  6. 6. 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.
  7. 7. 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;
  8. 8. 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
  9. 9. 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;
  10. 10. THE END
  11. 11. 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
  12. 12. 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

×