int main() { srand(time(0)); while (breakCond != 1) { printMenu(); selection(); switch(selector) { case 1: printf("Would you like, 1)Addition or 2)Multiplication?\n"); scanf("%d", &arithSelect); if (arithSelect != 1 && arithSelect != 2) { printf("You have made an invalid choice. Please start again.\n"); scanf("%d", &arithSelect); }; arithCollect(); avgTime = arithGame(maxValue, quant, arithSelect); score = score + numPoints(avgTime); break; case 2: printf("Enter the maximum number for the game:\n"); scanf("%d", &maxValue); avgTime = guessGame(maxValue); score = score + numPoints(avgTime); case 3: printf("Your score is %d.\n", score); break; case 4: printf("Thank you for playing!\n"); breakCond = 1; break; default: printf("This is an invalid value, please make a valid selection:\n"); selection(); break; }; }; };
// Main Function int main(void){ // Initilize Variables int selection, operation, max; int flag = 1; int score = 0; // Seed the random number generator just once srand(time(0)); // Create outer main loop while (flag){ // Print Main Options printf("Please make a selection from the following:\n"); printf("1. Play Arithmetic Game.\n"); printf("2. Play Guessing Game.\n"); printf("3. Print Score.\n"); printf("4. Quit.\n"); // Scan in selection scanf("%d", &selection); // Check selection and execute respective functions if (selection==1){ printf("Would you like, 1)Addition or 2)Multiplication?\n"); scanf("%d", &operation); printf("What is the maximum number you would like?\n"); scanf("%d", &max); score += arithGame(max, operation); } else if (selection==2){ score += guessGame(); } else if (selection==3){ printf("Your score is %d.\n\n", score); } else if (selection==4){ printf("Thank you for playing!\n"); flag = 0; } } // Program Completed, so return 0. return 0; }