c++ syntax error?

Discussion in 'Mac Programming' started by chris200x9, Oct 24, 2007.

  1. macrumors 6502a

    Joined:
    Jun 3, 2006
    #1
    hi I just can't see it can someone please tell me what is wrong with this function


    Code:
     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' );
    }
    
     
  2. thread starter macrumors 6502a

    Joined:
    Jun 3, 2006
    #2
    never mind I know what I did I somehow remembered to but a } to end a do loop but I never started it lol.
     

Share This Page