• Like

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

  • 77 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
77
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. ( if , if-else, if-else-if, switch..case)
  • 2. 1. if • if if (condition) { statement1; statement2; . . statement n; }
  • 3. int a,b,c; a =2; b = 5 ; c=a*b; If (c>=10) printf(“hello”);
  • 4. 2. if-else • if-else 2 if-else if if if else
  • 5. if –else If (condition) statement 1; else statement 2; If (condition) { statement 1; Statement2; } else { statement 3; Statement4; }
  • 6. int a,b,c; scanf(“%d”,a); scanf(“%d”,b); c= a+b; If (c>=10) printf(“hello”); else print(“Bye”)
  • 7. 3 if...else if • 2 ( ) if (condition) statement 1; else if(condition) statement2; else if(condition) statement-3; else statement 4;
  • 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. switch…case •
  • 10. Switch(variable) { case constant1 : statement 1; break; case constant 2: statement 2; break; case constant 3: statement3; break; default : statement4; }
  • 11. • variable int char • constant int char constant variable variable = constant case case • break ; case • default : switch …case variable constant case default
  • 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; }