Create a program based on the attached output using the do-while loop. Your program will keep asking the user to choose from the Options. And the program exits until the user selects Exit.
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
int ch=-1;
do{
printf("1. Menu item 1\n");
printf("2. Menu item 2\n");
printf("3. Menu item 3\n");
printf("4. Menu item 4\n");
printf("5. Exit\n");
scanf("%d",&ch);
switch(ch){
case 1:
{
printf("Menu item 1 is selected\n\n");
}
break;
case 2:
{
printf("Menu item 2 is selected\n\n");
}
break;
case 3:
{
printf("Menu item 3 is selected\n\n");
}
break;
case 4:
{
printf("Menu item 4 is selected\n\n");
}
break;
case 5:
//exit
break;
default:
printf("Invalid Input\n");
break;
}
}while(ch!=5);
return 0;
}
Comments
Leave a comment