// Example program
#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
usingnamespace std;
int numberOfGuesses=0;
int main();
do
{
cout << "Enter your number: ";
cin >> guess;
if (guess < number)
{
cout << "Your number is less than the secret number" << endl;
numberOfGuesses++;
}
elseif (guess > number)
{
cout << "Your number is more than the secret number" << endl;
numberOfGuesses++;
}
else
{
cout << "Your guess is correct!" << endl;
cout<<"You guessed in "<<numberOfGuesses<<" tries!";
}
}
while (guess != number);
system("PAUSE");
return 0;
}
The problem is the ; after main in line 9. Put a { there and should compile just fine.
; is used to declare a function, which is often found in header files, so the function body is defined elsewhere. In this case, do would be outside any function body, which is not allowed.