Would anyone be able to know a way I can make the program display the menu again to the user when their input is invalid?
Any other than copying and pasting the menu and if statements in the else.
Thanks,
Code:
#include <stdio.h>
#include <process.h>
#include <conio.h>
int meteorological_module();
int miscelleneous_module();
int main()
{
int reply_menu1 = 0;
int items_menu1 = 0;
clrscr();
printf(" This Program is still under development\n\n");
printf(" Here are the menu options that this program offers: \n\n");
printf(" %d. Select this option to go to the METEOROLOGICAL modules"
" program\n", 1);
printf(" %d. Select this option to go to the MISCELLANEOUS modules"
" program\n", 2);
printf(" %d. Enter three or a higher number to exit from this"
" program\n", 3);
printf(" Choose your option: ");
scanf("%d", &reply_menu1);
if (reply_menu1 == 1)
{
printf("\n You have chosen for the METEOROLOGICAL program\n");
meteorological_module();
}
if (reply_menu1 == 2)
{
printf("\n You have chosen for the MISCELLANEOUS program\n");
miscelleneous_module();
}
if (reply_menu1 == 3)
{
printf ("\n Youv'e decided to QUIT, good-bye.");
}
else
{
printf ("\n Your choice is out of range. Please re-enter, make sure"
" your input is valid.");
}
getch();
return 0;
}