English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include

int main()
{
cout << "GUESSING GAME" << endl;

int b;
int a;
a = rand() %50 + 14;

cout << "What do this the number is:" << endl;
cin >> b;

if(b == a)
{
cout << "You have guessed right" << endl;
}else
if(a < b)
{
cout << " U have guesssed TOO HIGH";
}else
if(a > b)
{
cout << "I think U have quessed low";
}
}
return (0);
}

2006-10-31 14:05:45 · 4 answers · asked by Best Helper 4 in Computers & Internet Programming & Design

--------------------Configuration: random - Debug--------------------
Compiling source file(s)...
random.cpp
In file included from C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\iostream.h:31,
from random.cpp:1:
C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.
random.cpp:27: error: syntax error before `return'
random.cpp:28:2: warning: no newline at end of file

random.exe - 1 error(s), 2 warning(s)

2006-10-31 14:06:10 · update #1

4 answers

you've got an extra curly brace '}' before the return.

2006-10-31 14:12:03 · answer #1 · answered by n0body 4 · 1 0

Why 've u put so many braces? It's confusing to handle too many of them, so u've missed one. Don't worry.

#include

int main()
{ //brace1 starts
cout << "GUESSING GAME" << endl;

int b;
int a;
a = rand() %50 + 14;

cout << "What do this the number is:" << endl;
cin >> b;

if(b == a)
cout << "You have guessed right" << endl;

else
{ //brace2 starts

if(a < b)
cout << " U have guesssed TOO HIGH";

else if(a > b)
cout << "I think U have quessed low";

} //brace2 ends

return (0);
} //brace 1 ends

Now okay ?

2006-10-31 22:17:25 · answer #2 · answered by Innocence Redefined 5 · 0 0

The problem is down at the bottom. You only need one }, not the two you have above return.

You also need to change #include to:
#include
using namespace std;


(The second bit you don't need if you want to prefix things with std::).

2006-10-31 22:10:56 · answer #3 · answered by renegadeconformist 2 · 0 0

and top to
#include
using namespace std;

change the bottom to
}
return (0);
}

2006-10-31 22:16:10 · answer #4 · answered by no one 3 · 0 0

fedest.com, questions and answers