QUOTE(Renzokusen @ 15 Mar, 2008 - 12:35 PM)

ah, its just I just read somewhere smaller programs always run better than larger and you should strive to make your programs as small as possiable. Thanks
No exactly smaller. More like less repetitive. However, getting rid of all the code you don't need is good. Never using globals if at all possible is good. Taking code you use over and over again and making it into a function or method will make things smaller.
Here's an example given the code you've offered.
This code gets used over and over. I'm not sure why you'd want it, but at least only do it once.
CODE
//check if input is correct
bool checkForBadInput() {
if(!cin) {
cout << "bad input\n\n";
bad_input= true; //if not set token
cin.clear(); //take cin out of 'fail' state
cin.ignore(INT_MAX, '\n'); //ignore the input made earlier
return true;
}
return false;
}
Another thing you do a lot of is ask the user for int, to the point of making yes and no an int. And you use that funky checker. Make that a single call. Notice here, there's no need for globals. Our check returns a boolean.
CODE
int getUserIntWithCheck() {
int response;
do {
cin >> response;
} while(checkForBadInput());
return response
}
One more bit of code to play with, the add function. There's a whole lot that could get fixed here, but the worst thing is that it calls itself. The next worse is that a lot of code repeats. Give the two functions we already made, the function might work like so:
CODE
void add() {
// loop until they want to leave
while (true) {
int firstNum = rand() % 101;
int secondNum = rand() % 101;
int correctAnswer = firstNum + secondNum;
cout << "\n*****Addition*****\n\n";
cout << " Solve: " << firstNum << " + " << secondNum << " = ? \n";
int playerAnswer = getUserIntWithCheck()
if (playerAnswer == correctAnswer) {
cout << "\nCongratulations you're CORRECT!\n";
} else {
cout << "Sorry you are incorrect\nThe correct answer is "<< correctAnswer << "\n";
}
cout << "\n Another probelm? [1] Yes \t [2] No \n";
if (getUserIntWithCheck()!=1) {
cout << "\n***Exiting back to main menu***\n";
return;
}
}
}
Again, never a need for a global.
Since you know you have other operations to test for, even add is overkill, you could very well write a single function with that looked like this.
CODE
bool solveProblem(char oper, int a, int b, int ans) {
// sorry, you can to write this
}
Hope this helps.