Code:
void additionmenu()
{
int choice;
printf("Please select the level\n");
printf("1 level 1\n");
printf("2 level 2\n");
printf("3 level 3\n");
scanf("%d", &choice);
if (choice == 1)
{
printf("You have selected level 1\n");
addEasy();
}
else if (choice == 2)
{
printf("You have selected level 2\n");
addMedium();
}
else if (choice == 3)
{
printf("You have selected level 3\n");
addDifficult();
}
else
{
printf("Invalid choice\n");
menu();
}
}
here my menu
int main()
{
int choice = menu();
printf("You have selected the choice %d\n", choice);
if (choice == 1)
{
printf("You have selected addition\n");
additionmenu();
}
else if (choice == 2)
{
printf("You have selected subtraction\n");
subtractionmenu();
}
else if (choice == 3)
{
printf("You have selected multiplication\n");
multiplicationmenu();
}
else if (choice == 4)
{
printf("You have selected division\n");
divisionmenu();
}
else
{
printf("Invalid choice\n");
}
system("pause");
}
int menu()
{
int choice;
printf("1. Addition\n");
printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Dividion\n");
printf("Please choose either 1,2 ,3 or 4 :\n");
scanf_s("%d", &choice);
(getchar() != '\n');
return choice;
}
after invalid i call the menu and menu can display but when i choose i show nothing, cannot continue to do