Answer to Question #300368 in C for Nobody

Question #300368

Create a C program that the user can make a selection.


Sample Output :

E or e for Even

O or o for Odd

X or x for Exit

A Character that is not on the selection print Error!


1
Expert's answer
2022-02-20T14:40:04-0500




#include<conio.h>
#include<stdio.h>
#include<string>
#include<stdlib.h>




int main(){
	char character;


	do{
		printf("E or e for Even\n");
		printf("O or o for Odd\n");
		printf("X or x for Exit\n");
		printf("Your selection: ");
		scanf("%c",&character);
		character=tolower(character);


		switch(character){
		case 'e':
			printf("Even\n");
			break;
		case 'o':
			printf("Odd\n");
			break;
		case 'x':
			break;
		default:
			printf("A Character is not on the selection\n\n");
			break;
		}
		fflush(stdin);
	}while(character!='x');


	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

Nobody
21.02.22, 13:38

Thank you for helping me. I appreciate your work. God bless to you.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS