This is the code I have so far. I am suppose to create a math game that will allow users to practice there times tables. The only problem is the instructor wants it to start out with 1*2=.. then go all the way to 10, and the next set to be 2*1= etc. I have no clue how to make the 'ones' the only one that has to start out by multiplying itself by 2.
EX:
1*2 =
1*3 =
1*4 =
1*5 =
1*6 =
1*7 =
1*8 =
1*9 =
1*10 =
2*1 = etc..
3*1 = etc..
The code I have written starts all the first numbers out by 2.
No, your code is fine. Perhaps you need to rebuild your project, or change your prefetch settings (if you're running Vista, the prefetch "feature" can have adverse effects on debugging and rerunning your program).
It's pretty easy. You've already defined firstNumber & secondNumber outside of the loops, so you can access them whenever you want.
In this case, a simple if conditional will be sufficient. Just make it check whether firstNumber is equal to 1. If so, assign the value of 2 to secondNumber; if not assign the value of 1 to secondNumber.
fun2code (646) Thanks! That worked just perfectly! Could you help with a break statement?
I need it to jump out of the outer loop if a negative number is inputted and exit the complete program if 0 is inputted. I have tried putting in an "if" loop with a break statement but it doesn't work. Could I use to goto or jump statement?
You're welcome for the help.
About your new questions...
I need it to jump out of the outer loop if a negative number is inputted and exit the complete program if 0 is inputted.
Do you mean jump out of the inner loop (the for(secondNumber...) loop)? Jumping out of the outer loop ( for(firstNumber) ) would be leaving the program.
To jump out of the inner loop do this after line 24: if( inputNumber < 0 )break;
To quit the program from within the inner loop you can go 2 ways.
1) Return directly from there:
if( inputNumber==0 )
{
system("pause");
return 0;
}
Some may frown on this method though.
2) Exit the inner loop with: if( inputNumber <= 0 )break;
Then exit the outer loop with if( inputNumber == 0 )break; placed after line 41.