Presentation is loading. Please wait.

Presentation is loading. Please wait.

If/else and switch. Assignments Due – Lab 3 No reading – study for your quiz!

Similar presentations


Presentation on theme: "If/else and switch. Assignments Due – Lab 3 No reading – study for your quiz!"— Presentation transcript:

1 if/else and switch

2 Assignments Due – Lab 3 No reading – study for your quiz!

3 Example if(num > 0 && num <= 10) printf(“Your number is between 1 and 10”);

4 Example if(num > 0 && num <= 10) printf(“Your number is between 1 and 10”); else printf(“Your number is not between 1 and 10”);

5 Nested if Statements if(condition) { if(condition) statement else statement }

6 Example if(num > 0) { if(num <= 10) { printf(“Right on, number between 1 and 10”); } else { printf(“Sorry, your number is too high”); } } else { printf(“Your number is too low.”); }

7 Example if(num > 0 && num <= 10) printf(“Your number is between 1 and 10”); else if(num>10) printf(“Your number is too high”); else printf(“Your number is too low);

8 switch Statement switch(num) { case 1: printf(“One”); break; case 2: printf(“Two”); break; default: printf(“Number not one or two”); }


Download ppt "If/else and switch. Assignments Due – Lab 3 No reading – study for your quiz!"

Similar presentations


Ads by Google