cant find where the error is can someone help?
I get the error missing ';' before '{' but cant find where its missing or do these errors have other meanings?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void welcome();
void goodbye();
int guess();
int getRandomNumber();
void checkit(int);
int main()
{
int returnedValue = 0;
welcome();
int theNumber = getRandomNumber();
cout << theNumber << endl;
while (returnedValue != theNumber) {
checkit(theNumber);
}
while(returnedValue == theNumber) {
cout << "you got it" << endl;
}
goodbye();
system("pause");
return 0;
}
void welcome()
{
cout <<"welcome to the guessing game" << endl;
}
void goodbye()
{
cout << "thanks for playing" << endl;
}
int guess()
{
int num;
cin >> num;
return num;
}
int getRandomNumber()
{
srand(time(0));
return rand() % 100+1;
}
void checkit(int theNumber)
{
int returnedValue = 0;
while (true) {
cout << "enter a number between 1 & 100" << endl;
if(!(cin >> returnedValue)){
cin.clear();
cin.ignore(256, '\n');
cout << "Sorry, must be a number\n\n";
continue;
}
if(returnedValue < 0 || returnedValue > 100) {
cin.clear();
cin.ignore(256, '\n');
cout << "Sorry, guess between 1 and 100\n\n";
continue;
}
break;
}
if (returnedValue > theNumber) {
cout << "Too high!\n\n";
}else (returnedValue < theNumber) {
cout << "Too low!\n\n";
}
}
|
You seem to have added an extra bracket on line 77. Either that, or you accidently removed a chunk of your code (like an else statement).
Last edited on
Topic archived. No new replies allowed.