I tried to do control flow graph for this coding (White box testing)
#include<stdio.h>
int main()
{
int choice;
printf("Enter your choice(Enter -99 to exit): ");
scanf("%d",&choice);
while(choice != -99) {
switch(choice) {
case 1:
printf("Green\n");
break;
case 2:
printf("Orange\n");
break;
case -1:
printf("Bye\n");
break;
default:
printf("Invalid option\n");
}
printf("Enter your choice: ");
scanf("%d",&choice); }
return 0;
}
This is the answer I so far tried
I don't know weather this is correct or not. I tried to do the rest of it.But I couldn't do. I tried and search so many times, but no satisfied answers are there. Please tell how to do it correctly.
I did questions using if else but not complex questions. This is not my homework question. Just trying to get knowledge using switch case..
Aucun commentaire:
Enregistrer un commentaire