1. Create a program based on the attached output using the do-while loop.
2. Your program will keep asking the user to choose from the Options.And the program exits until the user selects Exit.
#include <stdio.h>
int main()
{
int option;
do {
printf("Please choose options:\n");
printf("(1) Option number 1\n");
printf("(2) Option number 2\n");
printf("(3) Option number 3\n");
printf("(4) Exit\n");
printf("Enter: ");
scanf("%d", &option);
if (option < 0 | option > 4)
printf( "Invalid options\n\n" );
else if (option != 4)
printf( "Option %d selected\n\n", option);
} while ( option != 4 );
printf( "Exit\n" );
return 0;
}
Comments
Leave a comment