Labs                                        Assignments
First Term First Term
Second Term Second Term

 

Good Programming Practices

  1. Plan on paper before typing on computer when you attempt to write a program. Pseudocode is almost always the answer to a major problem.
  2. Use printf or scanf statements to find errors in your program.
  3. Identing your code to make it more readable.
  4. Commenting your code liberally . This is important, a mark is usually lost on the labs if you fail to document your program effieciently.
  5. Choose meaningfull variable names.
  6. Use underscores in long variable names to make them more readable i.e. this_is_your_age.
  7. There should be no more than one statement per line.
  8. Use identifiers of 31 or fewer characters. This helps ensure portability and can avoid some subtle programming errors.

 

Common Errors

  1. Forgetting to terminate a comment line with */ or starting a comment with */.
  2. Mismatched braces {}. To be sure you have the right number count them, if they are even then maybe you have misplaced them, if odd then your missing at least one.
  3. Typing the name of the output function printf as print in a program.
  4. Using a capital letter where a lower case should be used. C is CaseSensitive!
  5. Forgetting one or both of the double quotes surrounding the format control string of a printf or scanf.
  6. Placing an escape sequence such as \\n outside the format control string of a printf or scanf.
  7. Confusing the equality operator = = with the assignment operator =.
  8. Forgetting to terminate a statement with a semi-colon;
  9. An attempt to divide by zero is normally undefined on computer systems & generally results in a fatal error i.e. a crash.