question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dattts@gmail.com

    question

    hi i have a doubt. consider i as a intiger variable. then what is the
    meaning of statement i+=1;
  • Richard Heathfield

    #2
    Re: question

    dattts@gmail.co m said:
    hi i have a doubt. consider i as a intiger variable. then what is the
    meaning of statement i+=1;
    See K&R2, page 50, or Deitel & Deitel (5th edition), page 85, or Harbison &
    Steele (4th edition), page 223 - or if you have some other reference book,
    simply look up += in your C book's index. If you don't have a C reference
    book, get one - preferably one of the above, or "C Programming: A Modern
    Approach" by K N King (which I don't actually have, but apparently it's
    very good).

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • dattts@gmail.com

      #3
      Re: question

      THANK YOU FOR YOUR SUJJESTION SIR

      Comment

      • santosh

        #4
        Re: question

        In article
        <264c6ce2-a0f0-4c28-b927-9ea178c5f640@e2 3g2000prf.googl egroups.com>,
        dattts@gmail.co m <dattts@gmail.c omwrote on Saturday 24 Nov 2007 2:39
        pm:
        hi i have a doubt. consider i as a intiger variable. then what is the
        meaning of statement i+=1;
        This is functionally equivalent to the three statements below:

        i = i + 1;

        i++;

        ++i;

        Specifically, it is a shorthand notation for the first one. Others are:

        x /= y; (for x = x / y;)
        x -= y; (for x = x - y;)
        x *= y; (for x = x * y;)
        x %= y; (for x = x % y;)
        x >>= y; (for x = x >y;)
        x <<= y; (for x = x << y;)
        x &= y; (for x = x & y;)
        x |= y; (for x = x | y;)
        x ^= y; (for x = x ^ y;)

        These shorthand operators are called as assignment operators.
        Look them up in your textbook or reference.

        Comment

        • RoS

          #5
          Re: question

          In data Sat, 24 Nov 2007 15:15:28 +0530, santosh scrisse:
          >In article
          ><264c6ce2-a0f0-4c28-b927-9ea178c5f640@e2 3g2000prf.googl egroups.com>,
          >dattts@gmail.c om <dattts@gmail.c omwrote on Saturday 24 Nov 2007 2:39
          >pm:
          >
          >hi i have a doubt. consider i as a intiger variable. then what is the
          >meaning of statement i+=1;
          >
          >This is functionally equivalent to the three statements below:
          ^^^

          to one of the three statements below
          i = i + 1;
          >
          i++;
          >
          ++i;
          >
          >Specifically , it is a shorthand notation for the first one. Others are:
          >
          x /= y; (for x = x / y;)
          x -= y; (for x = x - y;)
          x *= y; (for x = x * y;)
          x %= y; (for x = x % y;)
          x >>= y; (for x = x >y;)
          x <<= y; (for x = x << y;)
          x &= y; (for x = x & y;)
          x |= y; (for x = x | y;)
          x ^= y; (for x = x ^ y;)
          yes they are very good
          >These shorthand operators are called as assignment operators.
          >Look them up in your textbook or reference.

          Comment

          • santosh

            #6
            Re: question

            In article <8qaik3dglls1k6 nuvnvj0jjma6ltj vo44h@4ax.com>, RoS
            <Ros@not.existw rote on Sunday 25 Nov 2007 1:50 pm:
            In data Sat, 24 Nov 2007 15:15:28 +0530, santosh scrisse:
            >
            >>In article
            >><264c6ce2-a0f0-4c28-b927-9ea178c5f640@e2 3g2000prf.googl egroups.com>,
            >>dattts@gmail. com <dattts@gmail.c omwrote on Saturday 24 Nov 2007 2:39
            >>pm:
            >>
            >>hi i have a doubt. consider i as a intiger variable. then what is
            >>the meaning of statement i+=1;
            >>
            >>This is functionally equivalent to the three statements below:
            ^^^
            >
            to one of the three statements below
            >
            > i = i + 1;
            >>
            > i++;
            >>
            > ++i;
            Yes, you are right. I should have said "effectivel y" instead
            of "functional ly", and qualified that it was only for the particular
            case presented by the OP.

            <snip>

            Comment

            • oNKoNec

              #7
              Re: question

              You should feel ashamed for asking so simple question!

              Comment

              • CBFalconer

                #8
                Re: question

                oNKoNec wrote:
                >
                You should feel ashamed for asking so simple question!
                Meaningless.

                If you want to post a followup via groups.google.c om, ensure
                you quote enough for the article to make sense. Google is only
                an interface to Usenet; it's not Usenet itself. Don't assume
                your readers can, or ever will, see any previous articles.

                More details at: <http://cfaj.freeshell. org/google/>

                --
                Chuck F (cbfalconer at maineline dot net)
                <http://cbfalconer.home .att.net>
                Try the download section.



                --
                Posted via a free Usenet account from http://www.teranews.com

                Comment

                • pete

                  #9
                  Re: question

                  santosh wrote:
                  >
                  In article <8qaik3dglls1k6 nuvnvj0jjma6ltj vo44h@4ax.com>, RoS
                  <Ros@not.existw rote on Sunday 25 Nov 2007 1:50 pm:
                  >
                  In data Sat, 24 Nov 2007 15:15:28 +0530, santosh scrisse:
                  >In article
                  ><264c6ce2-a0f0-4c28-b927-9ea178c5f640@e2 3g2000prf.googl egroups.com>,
                  >dattts@gmail.c om <dattts@gmail.c omwrote on Saturday 24 Nov 2007 2:39
                  >pm:
                  >
                  >hi i have a doubt. consider i as a intiger variable. then what is
                  >the meaning of statement i+=1;
                  >
                  >This is functionally equivalent to the three statements below:
                  ^^^

                  to one of the three statements below
                  i = i + 1;
                  >
                  i++;
                  >
                  ++i;
                  >
                  Yes, you are right. I should have said "effectivel y" instead
                  of "functional ly", and qualified that it was only for the particular
                  case presented by the OP.
                  However, if (i) were to be defined as a macro
                  for an lvalue with side effects, then
                  i+=1;
                  would mean exactly the same thing as either
                  i++;
                  or
                  ++i;
                  but not exactly the same thing as
                  i = i + 1;

                  --
                  pete

                  Comment

                  Working...