Download presentation
Presentation is loading. Please wait.
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”); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.