PDA

View Full Version : c++ syntax error?




chris200x9
Oct 24, 2007, 08:10 PM
hi I just can't see it can someone please tell me what is wrong with this function


void SubtractionProblems(int& subAtt, int& subCorr)
{
int x, y;
int answer;
char op;

// generate two random numbers
x = rand() % 5 + 5;
y = rand() % 5 + 1;

// display to the user
cout << "What is " << x << " - " << y << "? ";

// get answer
cin >> answer;
if( answer == x - y ) {
cout << "Congratulations! You got it right." << endl;
// increment number of correct
subCorr++;
}
else {
cout << "Sorry, but that answer was incorrect." << endl;
} // end if

cout << "Would you like to do another one (y/n)? ";
cin >> op;
} while( op == 'y' || op == 'Y' );
}



chris200x9
Oct 24, 2007, 08:17 PM
never mind I know what I did I somehow remembered to but a } to end a do loop but I never started it lol.