Whats wrong with my code? X-(
When I try to compile, I get:
help.cpp:5: error: expected unqualified-id before ‘{’ token
#include%26lt;iostream%26gt;
using namespace std;
int main(void);
{
double dnumber1 = 0.0;
double dnumber2 = 0.0;
double dnumber3 = 0.0;
double daverage = 0.0;
cout %26lt;%26lt; "Please enter 3 numbers: " %26lt;%26lt; endl;
cin %26gt;%26gt; dnumber1;
cin %26gt;%26gt; dnumber2;
cin %26gt;%26gt; dnumber3;
daverage = (dnumber1 + dnumber2 + dnumber3) / 3;
cout %26lt;%26lt; "The average of those 3 numbers is: " %26gt;%26gt; daverage %26lt;%26lt; endl;
system("pause");
return 0;
}
What's wrong with my C++?
Here's what I think might be the problem:
First, move your dnumber1-3 declarations to before int main().
Secondly, change the %26gt;%26gt; b/n "The average is..." and daverage to %26lt;%26lt;
Reply:Why the semicolon after "int main(void)"?
Reply:You can't have a semicolon after int main(void)
This line is also wrong:
cout %26lt;%26lt; "The average of those 3 numbers is: " %26gt;%26gt; daverage %26lt;%26lt; endl;
everything should be going this way %26lt;%26lt;
floral design
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment