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” |
#include <stdio.h>
int main() {
char colour = red;
switch (colour) {
case blue:
printf("no virus");
break;
case yellow:
printf("needs to be under observation ");
break;
case red:
printf("needs to be admitted in covid ward");
break;
default:
printf("safe");
break;
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.