Answer to Question #299747 in C for Nobody

Question #299747

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.


1
Expert's answer
2022-02-19T02:38:53-0500


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS