Switch statements

Rock-paper-scissors.

 Write a switch statement that checks nextChoice. If 0, print “Rock”. If 1, print “Paper”. If 2, print “Scissors”. For any other value, print “Unknown”. End with newline. Do not get input from the user; nextChoice is assigned in main().
#include <stdio.h>

int main(void) {
 int nextChoice;

nextChoice = 2;


 switch(nextChoice){
 case 0:
printf("Rock\n");
break;
case 1:
printf("Paper\n");
break;
case 2:
printf("Scissors\n");
break;
default:
printf("Unknown\n");
break;
}

return 0;
}

Switch statement to convert letters to Greek letters.

 Write a switch statement that checks origLetter. If ‘a’ or ‘A’, print “Alpha”. If ‘b’ or ‘B’, print “Beta”. For any other character, print “Unknown”. Use fall-through as appopriate. End with newline.
#include <stdio.h>

int main(void) {
 char origLetter;

origLetter = 'a';

switch(origLetter){
case 'A':
printf("Alpha\n");
break;
case 'a':
printf("Alpha\n");
break;
case 'B':
printf("Beta\n");
break;
case 'b':
printf("Beta\n");
break;
default:
printf("Unknown\n");
break;

}

return 0;
}