0


#include <cs50.h> 


int main (void)


 { 



int height; 


               do

      

        {



               height = get_int ("Enter Height");


        }
 

  
 
              while(height<1||height>8);
 

 int row;
      

        {   


              for ( row =0; row<height; row++)

        }



int space;


       {


               for ( space=0; space<height-row-1;space++)


       }




       {      

     

           printf(" ");


       }


int column;



       {


               for  (column=0; column<=row; column++)



       }




               printf("#");



 }
$ cd workspace 

$ clang mario.c

mario.c:23:9: error: expected statement

        }

        ^

mario.c:28:8: error: expected statement

       }

       ^

mario.c:39:8: error: expected statement

       }

       ^

3 errors generated.

What is the problem with my curly braces?

1

Curly braces help define scopes (range of allowed operation) for variables and statements in C and some other languages. They also help in defining coding styles. The CS50 course uses a particular style for C programming and style50 check will mark you down if you do not follow the guideline. You can check the guideline on the course website.

1
  • Also, the placement of curly brace pairs in relation to for statements is wrong. You should review the construction of for loops and spend some quality time with style50 learning the proper use of spaces and line feeds.
    – Cliff B
    Feb 2 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .