Question
Rewrite the following C program using switch-case statement.
and give me an output please
use printf and scanf
#include<stdio.h> int main(void) { int semester;
printf("What is your Studying Level (1-8)?> "); scanf("%d" , &semester); if(semester == 1 || semester == 2) printf("Your are a freshman!\n "); else if(semester == 3 || semester == 4) printf("Your are sophomore!\n "); else if(semester == 5 || semester == 6) printf("Your are junior!\n "); else if(semester == 7 || semester == 8) printf("Your are senior!\n "); else printf("You entered wrong level!\n");
printf("< Your name >\n"); printf("< Your ID >\n"); return 0; } |
#include<stdio.h> int main(void) { int semester; printf("What is your Studying Level (1-8)?> "); scanf("%d" , &semester); switch(semester){ case 1: case 2: printf("Your are a freshman!\n "); break; case 3: case 4: printf("Your are sophomore!\n "); break; case 4: case 6: printf("Your are junior!\n "); break; case 7: case 8: printf("Your are senior!\n "); break; default: printf("You entered wrong level!\n"); } printf("< Your name >\n"); printf("< Your ID >\n"); return 0; }
Get Answers For Free
Most questions answered within 1 hours.