1. ## Adding Random Numbers help

I need to create a program where the user selects addition, subtraction, or multiplication, and when they select one, 2 random numbers appear, and they must put in the right answer. The problem is, i cant get the correct answer. It just says: Would you like to play again?

Code:
```#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void problemType();
bool goAgain();

int calculateRandomNumber();

int choice = 0;
float randomNumber = 0;

int main(){
srand((unsigned)time(0));

do {
problemType();
}while(goAgain());
system("cls");

cin.get();
cin.get();
return 0;
}

{
cout<<"Welcome to my math game program. Sit back and enjoy!!"<<endl;
cout<<endl;
}

void problemType()
{

cout << "Enter the number for the problem type desired:" << endl;
cout << "1.  Addition"  << endl;
cout << "2.  Subtraction"  << endl;
cout << "3.  Multiplication"  << endl;
cout << "Enter choice: ";
cin >> choice;

if (choice==1){
cout << calculateRandomNumber();
cout << " + ";
cout << calculateRandomNumber();
cout << " = ";

else if (choice==2){
cout << calculateRandomNumber();
cout << " - ";
cout << calculateRandomNumber();
cout << " = ";

else if (choice==3){
cout << calculateRandomNumber();
cout << " * ";
cout << calculateRandomNumber();
cout << " = ";

else{
cin >> choice;
}

}

bool goAgain()
{

cout << "Would you like to play again? ";

system("cls");
{
cout << "Invalid choice.  Would you like to go again? ";
}

cout << endl;

return true;
else
return false;
}

int calculateRandomNumber(){

return (rand()%100) + 1;
}```

2. You are not doing anything with the answer the user inputs (other than storing it).

3. Ok. But if i want to send the random numbers calculated , have it checked to see if it is right or wrong, and send it back, how would i do that? i have this so far:

Code:
```int calcRealAnswer(){
if (realAnswer == calculateRandomNumber + calculateRandomNumber){
cout << "Correct!";
}
else{
cout << "Wrong!";}```
BTW i am a noobie, so no burning please

4. If you do this

cout << calculateRandomNumber();
cout << " + ";
cout << calculateRandomNumber();

Then sure you're going to get different answers.

You need something like
a = calculateRandomNumber();
b = calculateRandomNumber();
cout << a << "+" << b;

etc

5. OK i understand and i fixed it. One more thing though. Is there a way so that after 3 guesses, it disables the user from entering anything else and it displays the real answer?

6. Just have a counter of the number of guesses.

7. Something like
Code:
```extern const int num_tries;
int tries = 0, response;
do
{
if(tries >= num_tries) {
std::cout << "It's okay; with hard work, learning disabilities can be largely overcome. The correct answer is " << answer << '.' << std::endl;
break;
}
else if(!tries) std::cout << "What is " << a << ' ' << op << ' ' << b << " ?" << std::endl;
else std::cout << "Sorry, that's not the right answer. Try again. (" << (num_tries - tries) << " tries left)" << std::endl;
std::cin >> response;