Difference in i++ and ++i command

Discussion in 'Programmer's Corner' started by joemmech, Feb 3, 2010.

  1. joemmech

    Thread Starter Member

    Jan 22, 2010
    32
    0
    I have a confusion between i++ and ++i command in the c++ program. What is the difference between i++ and ++i command and what is the best to use between the two commands?
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    ++i means that the variable i is incremented before it is used while i++ means the i is used and then incremented.

    hgmjr
     
  3. joemmech

    Thread Starter Member

    Jan 22, 2010
    32
    0
    Thanks...It really helped a lot
     
Loading...