[go: up one dir, main page]

0% found this document useful (0 votes)
19 views3 pages

Style and Formatting Guidance

C Style

Uploaded by

anacisil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Style and Formatting Guidance

C Style

Uploaded by

anacisil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Style & Formatting Guidance

File Header
Use the template below to create a file header for each homework
submission. The Sources of Help section is required for all submissions.
Document any sources of help you received on the assignment.
[Sample] I discussed how to use scanf in a while loop with the tutor in
tutoring center / with Parker Porter who took this class last semester.
If you did not use any resources outside class and did not discuss solutions
with another student, use N/A.

Code Formatting Guidance


See the sample program below as a reference.

 Code must be correctly and consistently indented.


 The only code on the left column are: #include statements, #define
statements, function definitions and function closing braces.
o Example: lines 15, 43
 Variable declarations and executable statements in a function are
indented.
o Example: line 16 and following
 Indentation should be 4 spaces. Minimum acceptable is 2 spaces;
maximum 6. Do not use odd numbers of spaces.
 Each new block must be indented. Blocks include: if and else
statements, for loops, while loops, function bodies.
o Example: lines 26 - 36
 The opening brace for a new block must be at the end of the same
line as the defining keyword.
o Example: lines 25, 26
 The closing brace for a block is left-aligned with the defining
keyword.
o Example: lines 29, 37
 Spaces must be used to keep code readable. This includes spaces
following keywords (if, for, while, etc.) and around operators.
o Example: lines 16, 25, 26, 28
 There is no space between a function call and its argument list (e.g.
main, printf, scanf).
o Example: lines 15, 23, 25
 Comments for variables are placed to the right of the variable
declaration.
o Example: lines 16, 17
 Comments for code should be placed immediately above the line of
code being commented (not to the right).
o Example: lines 24, 35

You might also like