Consider the code below it is a simple menu driven system
#include
/* Function prototypes */
void fnOption1(void);
void fnOption2(void);
void fnOption3(void);
int main(void)
{
int nChoice = 1; /* Need an initial value */
while(nChoice != 4)
{
printf("nMain Menu ...n");
printf("1 Option 1n");
printf("2 Option 2n");
printf("3 Option 3n");
printf("4 Exitnn");
printf("Please enter your choice : ");
scanf("%d", &nChoice);
printf("n");
switch(nChoice)
{
case 1: fnOption1();
break;
case 2: fnOption2();
break;
case 3: fnOption3();
break;
case 4: break;
default: printf("Invalid input, please try againnn");
}
}
return 0;
}
void fnOption1(void)
{
printf("nYou selected Option1n");
}
void fnOption2(void)
{
printf("nYou selected Option2n");
}
void fnOption3(void)
{
printf("nYou selected Option3n");
}
Using this code as a starting point extend it as follows: