You're supposed to show the menu again after the user has made a selection other than B or Q.
You can use any type of loop, but do-while probably makes the most sense here.
I am relatively sure this is about actually entering the character 'B' (or 'Q') in the terminal rather than an actual keypress. In that case just use whatever method you use to get input (like cin for instance) and compare the result to B and Q.
//a program that use the selection and repetition constructs.
#include<iostream>
using namespace std;
int main()
{
int x1,x2;//two numbers
int x3;//the number system (the base)
int y;//the number of the operation
int sum,difference,product,quotient,remainder; //operators
char B='B';//to enter new numbers
char Q='Q';//to quit the program
cout << "Please Enter the two numbers: " << endl;
cin >>x1>>x2;
cout << "Enter the number system : " << endl;
cin >> x3;
do {cout << "Enter the number of the operation: " << endl;
cin >> y;
if (y==1)
{
sum = x1+x2;
cout << sum << endl;
}
else if (y==2)
{difference = x1-x2;
cout << difference << endl;
}
else
if (y==3)
{product = x1*x2;
cout << product << endl;
}
else
else if(y==5)
{
remainder = x1%x2;
cout << remainder << endl;
}
else if (y==Q)
{cout << "Quit" << endl;}
else if (y==B)
{cout << "Please Enter the two numbers: " << endl;
cin >>x1>>x2;
cout << "Enter the number system : " << endl;
cin >> x3;}
}
while(cout << "1. The sum of the two numbers " << endl
<< "2. The difference of the two numbers " << endl
<< "3. The profuct of the two numbers " << endl
<< "4. The quotient of the two numbers " << endl
<< "5. The remainder when the first number is divided by the second " << endl);
you realise that you canĀ“t do if (int == char) in your code?
without changing too much you can put somewhere that if y=6 then Q and if y=7 then B or whatever you want!
Or you can simply declare a char variable and read it...and you just make the test if (char_var=='B' and same for Q ....
I think that maybe the trap in the exercise: reading integers and characters to the same variable. The simpler way is to think '1','2' in term of characters instead of integers, read them as characters. But I think there's still some other problems in his code.