hi guys,i was trying to make user able to make selection again when they make an invalid input, but when i run this code,it just doesnt work that way,it goes printing the same line like crazy...did i do something wrong?
int main (void)
{
//Local Declarations
int menu;
//Statements
time_t mytime;
mytime = time(NULL);
printf(ctime(&mytime));
printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
printf("\t\t@ WELCOME TO CHEMY'S CHEMISTRY @\n");
printf("\t\t@ @\n");
printf("\t\t@ MAIN MENU @\n");
printf("\t\t@ @\n");
printf("\t\t@ 1. CHEMISTRY QUIZ @\n");
printf("\t\t@ 2. IDEAL GAS LAW CALCULATOR @\n");
printf("\t\t@ 3. OPTIONAL GAME @\n");
printf("\t\t@ @\n");
printf("\t\t@ 0. EXIT @\n");
printf("\t\t@ @\n");
printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
printf("Please choose your menu: ");
scanf("%d", &menu);
while(menu != 0)
{
switch(menu)
{
case 1: quiz();
break;
case 2: calculator();
break;
case 3: optional();
break;
case 0: printf("Goodbye\n");
break;
default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");
printf("Please choose your menu: ");
scanf("%d", &menu);
break;
}}
return 0;
}