Professional Documents
Culture Documents
Whitespaces are ignored by the compiler, so it does not affect our codes, but affect how we read our codes.
Code block delimiters (curly braces, { }) should be vertically aligned. Statements inside the code block shall be
indented.
The opening and closing curly braces ({ }) are vertically aligned specifying that they are inside the function body
of main(). Also, statements inside the code block are indented uniformly to specify that they are within the
function.
Use comments
Comments should be used to complement the source codes. Do not put on comments on those things that are
obvious, duplicating the language syntax. Also, it is not necessary to comment on each statement. Well chosen
identifiers and the use of self-documenting code generally eliminates the need for comments on some parts of
your code.
The use of a comment in this code is not necessary in this case, it just duplicates the language syntax.
Better to choose names from a usage perspective. The identifiers should explain themselves what they are. For
example, if you need a variable to store age, better to use “age” as an identifier.
Syntax Errors
Semantic Errors
Software Bug
- a problem in the source code that causes the program to produce an incorrect or unexpected result.
- When you have written a piece of code, it is important to test if it works correctly or not. If you find errors,
you need to debug it.
Use of Debugger
- another program that helps us in identifying how a program executes and examine the program state
while the program is running.
- We can use the debugger to execute a program line by line and examine the value of the variables.
Using breakpoints
- a code marker that tells the debugger to halt the execution of the program at the breakpoint.
Using Stepping