|
-
March 14th, 2012, 09:52 AM
#1
syntax error : '}'
hello
got syntax error : '}'
any help ?
PHP Code:
# include <iostream>
using namespace std;
int main () {
signed int max=50;
signed int sum=0;
signed int c;
signed int f;
signed int m;
for ( int i=1; i<max; ++i)
sum = sum + i;
cin >>c;
f=sum/c;
if ( f<100.0)
{
cout <<"low";
}
else
{
cout <<"high";
}
m=-50;
do {
m=m+5;
while ( m<50);
}
}
-
March 14th, 2012, 09:59 AM
#2
Re: syntax error : '}'
If you indented your code better, the problem would become apparent:
Code:
# include <iostream>
using namespace std;
int main () {
signed int max=50;
signed int sum=0;
signed int c;
signed int f;
signed int m;
for ( int i=1; i<max; ++i)
sum = sum + i;
cin >>c;
f=sum/c;
if ( f<100.0)
{
cout <<"low";
}
else
{
cout <<"high";
}
m=-50;
do {
m=m+5;
while ( m<50)
/* empty loop body */;
}
}
Where's the while to match the do?
-
March 14th, 2012, 10:00 AM
#3
Re: syntax error : '}'
The closing brace of your do statement should come before the while, not after it.
-
March 14th, 2012, 10:28 AM
#4
Re: syntax error : '}'
amazing thanks GCDEF & laserlight
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|