Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [C++] In the statement -- -- What does i++ mean?  (Read 20675 times)

0 Members and 1 Guest are viewing this topic.

liambiscuit

    Topic Starter


    Hopeful

    [C++] In the statement -- -- What does i++ mean?
    « on: April 24, 2009, 08:42:53 PM »
    -- The statement is
       for ( int i = 2; i < 30; i++ )
       {
       --
    Based on my assumption, i++ means i+1... but -- I don't code in C++ at all.
    " When the rich wage war its the Poor who die "
            Linkin Park



    Whoever said that nothing is impossible has obviously never tried to slam a revolving door. -- Lauren

    You cannot buy your friends but you can buy them pizza - AzureBlade49

    gh0std0g74



      Apprentice

      Thanked: 37
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #1 on: April 24, 2009, 10:05:27 PM »
      i++ mean post increment.  equivalent to i=i+1

      edit: it means "use the value of i first, then increment"
      « Last Edit: April 25, 2009, 07:25:07 PM by gh0std0g74 »

      Helpmeh



        Guru
      • Roar.
      • Thanked: 122
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 8
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #2 on: April 25, 2009, 10:25:19 AM »
      i++ mean post increment.  equivalent to i=i+1
      Like in batch,

      set /a num+=1
      Where's MagicSpeed?
      Quote from: 'matt'
      He's playing a game called IRL. Great graphics, *censored* gameplay.

      Geek-9pm



        Genius
      • Geek After Dark
      • Thanked: 641
        • Gekk9pm bnlog
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows XP
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #3 on: April 25, 2009, 06:23:26 PM »
      Like in batch,

      set /a num+=1

      C++  is NOT like batch at all.
      Already  the number of mobile-devices does  exceed the number of people in the world.

      x2543

      • Guest
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #4 on: April 25, 2009, 06:40:59 PM »
       
      C++  is NOT like batch at all.

      I think he meant to say that set /a num+=1 is the batch equivalent to the C++ command, does same type of thing.

      Geek-9pm



        Genius
      • Geek After Dark
      • Thanked: 641
        • Gekk9pm bnlog
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows XP
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #5 on: April 25, 2009, 06:51:39 PM »

      I think he meant to say that set /a num+=1 is the batch equivalent to the C++ command, does same type of thing.

      OK, I see what you mean. On my computer
      set /a num=+1
      gives the value as 1
      Maybe he meant
      set /a num=num+1
      Or did I miss something? What did I miss?
      Already  the number of mobile-devices does  exceed the number of people in the world.

      Helpmeh



        Guru
      • Roar.
      • Thanked: 122
        • Yes
        • Yes
      • Computer: Specs
      • Experience: Familiar
      • OS: Windows 8
      Re: [C++] In the statement -- -- What does i++ mean?
      « Reply #6 on: April 25, 2009, 07:27:15 PM »
      OK, I see what you mean. On my computer
      set /a num=+1
      gives the value as 1
      Maybe he meant
      set /a num=num+1
      Or did I miss something? What did I miss?

      set /a num+=1 and
      set /a num=%num%+1
      are the same thing. It will return 1 because a blank variable is equaled to 0, but also a blank line. In math, it's equaled to 0, but with echo it counts as nothing being there.
      Where's MagicSpeed?
      Quote from: 'matt'
      He's playing a game called IRL. Great graphics, *censored* gameplay.

      mohammad miyan



        Starter

        Re: [C++] In the statement -- -- What does i++ mean?
        « Reply #7 on: April 27, 2009, 12:54:37 AM »
        i++;

        simply mean
        i=i+1;
        i++; will just increament value of i by 1.

        in c,or c++
        i++,++i are same if. if they are not used with other variable.
        in the same way --i,i-- are  same.

        consider
        i=5;
        i++;

        now the value of i is simply 6;
        i=5
        ++i;
        again value of i is 6;

        but u just consider statement
        i=5;
        c=i++;
        the value of c is 5, i is 6.
        i=5;
        c=++i;
        the value of c is 6,i is 6;

        Ralph Spencer

        • Guest
        Beep
        « Reply #8 on: April 28, 2009, 01:26:46 AM »
        ++ is an unary increment operator which increments the value of the operand by 1. I'd recommend reading books about C++. :)

        Geek-9pm



          Genius
        • Geek After Dark
        • Thanked: 641
          • Gekk9pm bnlog
        • Computer: Specs
        • Experience: Experienced
        • OS: Windows XP
        Re: [C++] In the statement -- -- What does i++ mean?
        « Reply #9 on: April 28, 2009, 10:16:02 AM »
        Quote
        books about C++.
        So if I go to the library and ask for a book about C++
        they will give me a book about D
        Which comes after C.
        Is that right?   ::)
        Already  the number of mobile-devices does  exceed the number of people in the world.

        x2543

        • Guest
        Re: [C++] In the statement -- -- What does i++ mean?
        « Reply #10 on: April 28, 2009, 11:23:37 AM »
        So if I go to the library and ask for a book about C++
        they will give me a book about D
        Which comes after C.
        Is that right?   ::)

        very funny  :P

        Ralph Spencer

        • Guest
        Re: [C++] In the statement -- -- What does i++ mean?
        « Reply #11 on: April 29, 2009, 01:14:26 AM »
        Never knew your librarian uses a C++ compiler for everything that is told. Anyways you should get "Expression syntax" because "give" or "me" or "a" or "book" or "about" or "C++" none are valid in C++ syntax. Try
        Code: [Select]
        library.getBook("C++ for dummies");
        If that fails refer to the manual for that librarian.