Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- printf("Welcome to MathoMania\n");
- printf("\n*********************************************************\n");
- //user prompts to enter values
- int num1, num2;
- printf("Enter any two random numbers:\n");
- scanf("%d%d", &num1, &num2);
- printf("\n****************************MENU****************************\n");
- printf("1. Perform a Modulus Division on two numbers.\n");
- printf("2. Perform Multiplication on two numbers.\n");
- printf("3. Perform Subtraction of two numbers.\n");
- printf("4. Exit\n");
- int option;
- printf("\nPlease enter the number that coincides with your option.\n");
- scanf("%d", &option);
- int answer1, answer2, answer3;
- answer1 = num1 % num2;
- answer2 = num1 * num2;
- answer3 = num1 - num2;
- int answerFromUser1, answerFromUser2, answerFromUser3;
- int newAnswer1, newAnswer2, newAnswer3;
- switch (option)
- {
- case 1:
- printf("\nEnter the result:\n") ;
- scanf("%d", &answerFromUser1);
- if ( answerFromUser1 == answer1)
- printf("Congratulations your answer is correct!!!\n");
- else if ( answerFromUser1 != answer1)
- {
- printf("\nYour answer is incorrect.\n");
- printf("Please try again enter new answer:\n");
- scanf("%d", &newAnswer1);
- if ( newAnswer1 == answer1)
- printf("Congratulations your answer is correct!!!\n");
- else if ( newAnswer1 != answer1)
- {
- printf("Your answer is incorrect you have exhausted all your chances.\n");
- printf("The correct answer is %d.\n", answer1);
- }
- }
- break;
- case 2:
- printf("\nEnter the result:\n") ;
- scanf("%d", &answerFromUser2);
- if ( answerFromUser2 == answer2)
- printf("Congratulations your answer is correct!!!\n");
- else if ( answerFromUser2 != answer2)
- {
- printf("\nYour answer is incorrect.\n");
- printf("Please try again enter new answer:\n");
- scanf("%d", &newAnswer2);
- if ( newAnswer2 == answer2)
- printf("Congratulations your answer is correct!!!\n");
- else if ( newAnswer2 != answer2)
- {
- printf("Your answer is incorrect you have exhausted all your chances.\n");
- printf("The correct answer is %d.\n", answer2);
- }
- }
- break;
- case 3:
- printf("\nEnter the result:\n") ;
- scanf("%d", &answerFromUser3);
- if ( answerFromUser3 == answer3)
- printf("Congratulations your answer is correct!!!\n");
- else if ( answerFromUser3 != answer3)
- {
- printf("\nYour answer is incorrect.\n");
- printf("Please try again enter new answer:\n");
- scanf("%d", &newAnswer3);
- if ( newAnswer3 == answer3)
- printf("Congratulations your answer is correct!!!\n");
- else if ( newAnswer3 != answer3)
- {
- printf("Your answer is incorrect you have exhausted all your chances.\n");
- printf("The correct answer is %d.\n", answer3);
- }
- }
- break;
- case 4:
- break;
- }
- printf("\n*****************************************************************\n");
- printf("\nTHANKS FOR PLAYING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement