Level |
Components |
Example |
Explanation |
Required Syntax |
- preprocessor directives
- the main function
|
|
- If you don't include the correct library for functions you call but don't write, there will be a compiler error.
- All programs must have exactly one main function to compile and run.
|
Conventions |
- preprocessor directives
- the main function
- return 0; statement at the end
|
 |
- Macros are like labels which make values in your code easier to read
- a variable is not the right tool since the value doesn't change
- use all caps so you can tell the difference!
- The return 0; statement tells the operating system that the program finished running without issues.
|
Best Practices |
- header comments
- preprocessor directives
- only include libraries that are used in that program
- including "macros"
- the main function
- consistent indentation
- return 0 statement at the bottom
|
 |
- Header comments give the reader more information, like who wrote the program.
- Including libraries that aren't used can cause performance issues.
- Indentation makes code easier by indicating where different blocks of code begin and end.
|