โครงสร้างควบคุมการทำงานแบบควบคุมการทำงาน

203 views
152 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
203
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

โครงสร้างควบคุมการทำงานแบบควบคุมการทำงาน

  1. 1. ( if , if-else, if-else-if, switch..case)
  2. 2. 1. if • if if (condition) { statement1; statement2; . . statement n; }
  3. 3. int a,b,c; a =2; b = 5 ; c=a*b; If (c>=10) printf(“hello”);
  4. 4. 2. if-else • if-else 2 if-else if if if else
  5. 5. if –else If (condition) statement 1; else statement 2; If (condition) { statement 1; Statement2; } else { statement 3; Statement4; }
  6. 6. int a,b,c; scanf(“%d”,a); scanf(“%d”,b); c= a+b; If (c>=10) printf(“hello”); else print(“Bye”)
  7. 7. 3 if...else if • 2 ( ) if (condition) statement 1; else if(condition) statement2; else if(condition) statement-3; else statement 4;
  8. 8. int s; printf(“Enter your score”); scanf(“%d”,&s); If(s>90) printf(“A”); else if(s>=80) printf(“B”); else if(s>=70) printf(“C”); else printf(“D”);
  9. 9. switch…case •
  10. 10. Switch(variable) { case constant1 : statement 1; break; case constant 2: statement 2; break; case constant 3: statement3; break; default : statement4; }
  11. 11. • variable int char • constant int char constant variable variable = constant case case • break ; case • default : switch …case variable constant case default
  12. 12. switch…case Int a; Scanf(“%d”,&a); Switch(a) { case 0: printf(“zero”); break; case1 :printf(“red”); break; case2 : printf(“blue”); break; case3 : printf(“green”); break; case4 : printf(“yellow”); break; default : printf(“ Other case”); break; }

×