CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2010
    Posts
    75

    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=1i<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);
            }
            


  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    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?
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: syntax error : '}'

    The closing brace of your do statement should come before the while, not after it.

  4. #4
    Join Date
    Jul 2010
    Posts
    75

    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
  •  





Click Here to Expand Forum to Full Width

Featured