sum.c

  • Computers start counting from zero, however since humans are used to start counting from 1, we use i + 1 shift the output by 1 and make it more user friendly. This way we wont alter the value of i itself (i++ or i += 1 võid alter the value and make the loop misbehave).
  • According to the coding style, we should not declare multiple variables and initialize them on the same line. We will initialize them on separate line(s).
  • Right after declaring a variable, it will contain a random (garbage) value. If we want to use this variable, we need to make sure we assign a value before using it, for sum we will initialize  to 0.
  • By using #define we can avoid “magic numbers”