Small problem but need help

Write your question here.

 
   cout << "Enter your guess: ";



#include "stdafx.h"
#include <iostream>
#include <ctime>
#include "targetver.h"
using namespace std;
int main()
{




int iGumballs;
int iUserguess;
int iGuesses = 0;

while (true);



system("CLS");
cin.clear();
iGuesses = 0;

srand(static_cast<unsigned int>(time(0)));
iGumballs = rand() % 1000 + 1;
cout << "How many gumballs are in the gumball jar, you guess"
<< endl;


do;

cout << "Enter your guess: ";
cin >> iUserguess;


if (iUserguess > iGumballs);

cout << "Too High!" << endl << endl;



if (iUserguess < iGumballs);

cout << "Too Low!" << endl << endl;

iGuesses++;
while (iUserguess > iGumballs || iUserguess < iGumballs);
cout << "You guess the right amount of gumballs! High Five" <<

endl << endl;
cout << "You took" << iGuesses << " guesses " << endl << endl;
system("PAUSE");
return 0;

}



I was watching a youtube video and copying what the guy did for practice and I can't figure out how to figure that code.

I have two errors:

Error 1 error C2059: syntax error : 'if'
2 IntelliSense: expected 'while'

Thank you for your help.
the syntax for do - while loop is this :

1
2
3
4
5
6
7
8
9
do { // Note the bracket, you are missing this

// ....
// .... Codes
// ....


} while ( iUserguess > iGumballs || iUserguess < iGumballs );
// Note again the closing bracket 


and for while loop :
1
2
3
4
5
6
7
while ( true ) { // note this bracket

// ...
// ... Your code
// ...

} // note this bracket 
Last edited on
He did use those brackets a lot during the video. I thought the bracket at the start of the function and the ending bracket is all that is needed?
no, you will all those brackets, when one bracket is missing, you will not be able to compile your program
Topic archived. No new replies allowed.