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

3. Problem B (10 pts) Please change the switch statement in the following progra

ID: 3529774 • Letter: 3

Question

3. Problem B (10 pts) Please change the switch statement in the following program into an if-else statement (else if or nested if-else statement may be necessary). #include int main(void) { int data; printf("Enter value -1 or 0 or 1 "); scanf("%d",&data); switch(data) // Please change this part to if-else statement { case -1: printf("This is negative"); break; case 0: printf("This is zero"); break; case 1: printf("This is positive"); break;default: printf("You entered wrong value"); } return 0; }

Explanation / Answer

#include<stdio.h>

int main(void) {

int data;

printf("Enter value -1 or 0 or 1 ");

scanf("%d",&data);

if(data==-1)

printf("This is negative")

else if(data==0)

printf("This is zero");

else if(data== 1)

printf("This is positive");

else

printf("You entered wrong value");

return 0;

}

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