Return to main menu issue
Code:
#include <stdio.h>#include <stdlib.h>
#include <string.h>
// function prototype
int sale_menu();
int report_menu();
void AddSalesMan();
void QtrReport();
void SalesComm();
// sales processing system menu function
int sale_menu()
{
int menu;
system("cls");
printf("Sales Processing System\n");
printf("-----------------------\n\n");
printf("1. Add Salesman Records\n");
printf("2. Reports Generation\n");
printf("3. Modify Salesman Records\n");
printf("4. Delete Salesman Records\n\n");
printf("0. Exit\n");
printf("Your choice: ");
scanf("%d", &menu);
return menu;
printf("\n");
}
// reports generation menu function
int report_menu()
{
int report;
system("cls");
printf("Reports Generation\n");
printf("------------------\n\n");
printf("1. View Quarterly Sales Report\n");
printf("2. View Individual Salesman Commission\n\n");
printf("0. Return to Main Menu\n");
printf("Your choice: ");
scanf("%d", &report);
return report;
}
// function to add salesman
void AddSalesMan()
{
printf("add salesman\n");
system("pause");
} // end function AddSalesman
// function to generate report
void QtrReport()
{
printf("Qtr Report\n");
system("pause"); // pause the program before it exits
} // end function QtrReport
void SalesComm()
{
printf("Sales Commission\n");
system("pause");
}
// function main begins program execution
int main()
{
int getMenu = 10, getReport = 10; // menu selector
// call and assign sale_menu function to getMenu
getMenu = sale_menu();
printf("\n");
while (getMenu != 0)
{
// Execute command based on user input
switch(getMenu)
{
// call AddSalesMan function
case 1:
AddSalesMan();
break;
// call and assign report_menu to getReport
case 2:
// Prompt and read report to getReport
getReport = report_menu();
while (getReport != 0)
{
// call QtrReport function
if (getReport == 1)
QtrReport();
else if (getReport == 2)
SalesComm();
// Prompt and read report to getReport
getReport = report_menu();
} // end while
break;
} // end switch
}// end while
system("pause"); // pause the program before it exits
return 0;
} // end main
Why I cannot return to main menu from Report Generation?