initialization

This is a discussion on initialization within the C Programming forums, part of the General Programming Boards category; sometimes .. we initialize a variable to zero ! why? look at this algorithm for example ( nested loop ) ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    38

    initialization

    sometimes .. we initialize a variable to zero ! why?

    look at this algorithm for example ( nested loop ) :


    Code:
    totalSteps = 0
    FOR outsideCounter = 1 TO 5 INC BY 1
    FOR insideCounter = 1 TO 5 INC BY 1
    totalSteps = totalSteps + 1
    OUTPUT “Outside = “ outsideCounter,
    “ Inside = “, insideCounter,
    “ Total Steps = “, totalSteps
    ENDFOR
    ENDFOR

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,114
    Quote Originally Posted by abood1190
    sometimes .. we initialize a variable to zero ! why?
    Because it makes sense.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bad initialization?
    By oklem in forum C Programming
    Replies: 4
    Last Post: 12-18-2011, 10:27 AM
  2. C initialization
    By vpshastry in forum C Programming
    Replies: 10
    Last Post: 09-16-2011, 02:17 PM
  3. assignment vs initialization
    By KIBO in forum C++ Programming
    Replies: 3
    Last Post: 11-03-2010, 10:46 AM
  4. Initialization. Are they the same?
    By lockpatrick in forum C++ Programming
    Replies: 3
    Last Post: 08-22-2002, 12:46 AM
  5. Initialization question
    By cpp4ever in forum C++ Programming
    Replies: 0
    Last Post: 10-19-2001, 06:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21