Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C PROGRAM ONLY! 1. Write a switch statement that checks nextChoice. If 0, print

ID: 3884202 • Letter: C

Question

C PROGRAM ONLY!

1. 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 = 0;

nextChoice = 2;

/* Your solution goes here */

return 0;
}

2. 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';

/* Your solution goes here */

return 0;
}

Explanation / Answer

//Please see the code below please do thumbs up if you like the solution.

1. 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

#include <stdio.h>

int main(void)
{
   int nextChoice = 0;

   nextChoice = 2;

   /* Your solution goes here */
   switch(nextChoice)
   {
       case 0:
           printf("Rock ");
           break;
       case 1:
           printf("Paper ");
           break;
       case 2:
           printf("Scissors ");
           break;

        default:
           printf("Unknown ");
           break;
   }

   return 0;
}

OUTPUT:

Scissors

2. 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';

   /* Your solution goes here */
   switch(origLetter)
   {
       case 'a':
       case 'A':
           printf("Alpha ");
           break;
       case 'b':
       case 'B':
           printf("Beta ");
           break;
       default:
           printf("Unknown ");
           break;
   }

   return 0;
}

OUTPUT:

Alpha