Write a switch statement that uses the colour of a swab sample of COVID testing vehicle to send a message to a local doctor. Use the messages given for each colour in the table below. Justify your answer.
Colour |
Message |
Blue |
“No virus” |
Yellow |
“Needs to be under observation” |
Red |
“Needs to be admitted in COVID ward” |
SOURCE CODE
#include<stdio.h>
int main()
{
int n;
printf("Chose Colour: \n1. Blue\n2. Yellow\n3. Red\n");
scanf("%d", &n);
switch(n)
{
case 1:
printf("No virus\n");
break;
case 2:
printf("Needs to be under observation\n");
break;
case 3:
printf("Needs to be admitted in COVID ward\n");
break;
default:
printf("Wrong Input\n");
}
return 0;
}
OUTPUT SCREENSHOT
Comment bellow if you have any doubts.
Get Answers For Free
Most questions answered within 1 hours.