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

Rewrite the following code using if statements using C. #include <stdio.h> #incl

ID: 3557946 • Letter: R

Question

Rewrite the following code using if statements using C.

#include <stdio.h>
#include <stdlib.h>
int main()
{
int input;
do
{
printf( "1. Play game " );
printf( "2. Load game " );
printf( "3. Play multiplayer " );
printf( "4. Exit " );
printf( "Selection: " );
scanf( "%d", &input );
switch ( input )
{
case 1:
printf("Playing the game ");
break;
case 2:
printf("Loading the game ");
break;
case 3:
printf("Playing multiplayer ");
break;
case 4:
printf( "Thanks for playing! " );
break;
default:
printf( "Bad input! " );
break;
}
} while(input != 4);
system(

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>

int main()
{
int input;
do
{
printf( "1. Play game " );
printf( "2. Load game " );
printf( "3. Play multiplayer " );
printf( "4. Exit " );
printf( "Selection: " );
scanf( "%d", &input );

if(input==1)
printf("Playing the game ");

else if(input==2)
printf("Loading the game ");

else if (input==3)
printf("Playing multiplayer ");

else if(input==4)
printf( "Thanks for playing! " );

else
printf( "Bad input! " );


} while(input != 4);
system(

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote