Indentation and Code Format : Convention « Language « C Tutorial






while (! done) {   

        printf("Processing\n");    

        next_entry();  

    }  

    if (total <= 0) {  

        printf("You owe nothing\n");   

        total = 0; 

    } else {   

        printf("You owe %d dollars\n", total); 

        all_totals = all_totals + total;   

    }

In this case, curly braces ({}) are put on the same line as the statements.

The other style puts the {} on lines by themselves:

while (! done)     
    {  
        printf("Processing\n");    

        next_entry();  
    }  

    if (total <= 0)    
    {  

       printf("You owe nothing\n");    

       total = 0;  

    }  
    else   
    {  

       printf("You owe %d dollars\n", total);  

       all_totals = all_totals + total;    

    }








1.16.Convention
1.16.1.Indentation and Code Format
1.16.2.Clarity