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!
#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;
}
Comments
Thank you for helping me. I appreciate your work. God bless to you.
Leave a comment