Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my code what do i have to add to repeat the menu again at the end to con

ID: 3646216 • Letter: T

Question

This is my code what do i have to add to repeat the menu again at the end to continue the quiz?????



#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int num1, num2,choice=1,i=0,j=0,k=0,l=0,m=0,add_answered,sub_answered;
int add_result,sub_result;


cout<< rand() << endl;
cout<< rand() << endl;

num1= rand()% 10 + 1;
num2=rand()% 10 + 1;
do{
cout<<"Welcome To Arithmethic Quiz ";
cout<<"--------------------------- ";
cout<<"MENU: 1 Enter 1 for Addition ";
cout<<"2 Enter 2 for Subtraction ";
cout<<"5 Enter 5 to Exit ";
cin>>choice;
switch(choice)
{
case 1:i++;
do{
cout<<"addition of"<<num1<<"and"<<num2<<"?"<<endl;
cin>>add_answered;

if(add_answered!=(num1+num2))
{
cout<<"Entered correct answer,try again!";
l++;
}
m++;
}while(add_answered==(num1+num2));
break;
case 2:j++;
do{
cout<<"subtraction of"<<num1<<"and"<<num2<<"?"<<endl;
cin>>sub_answered;

if(sub_answered!=(num1-num2))
{
cout<<"Entered correct answer,try again!";
l++;
}
m++;
}while(sub_answered==(num1-num2));
break;
}
k++;
}while(choice!=5);
cout<<"Addition Problems Played:"<<i<<endl;
cout<<"subtraction Problems Played:"<<j<<endl;
cout<<"Total number of times played:"<<k<<endl;
cout<<"Answered correctly:"<<m<<endl;
cout<<"Incorrect answers"<<l;

return0;
}

Explanation / Answer

at the beginning of the program after the lines where you declare your variables, put a while loop, such as: while (true){ and then at the very end, just before the return 0, put a closing brace: } If you want to create a way to escape from it, you can pull in a variable at the end of your program, basically prompt "Exit? (y/n)" and then do a cin, check to see if it's a "y", and if so set a boolean exitvar to true. Then replace your while(true) with while (!exitvar).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote