Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Question on prefix and post fix

Question on prefix and post fix

Scheduled Pinned Locked Moved C / C++ / MFC
delphidatabasehelpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rohit dhamija 0
    wrote on last edited by
    #1

    Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit

    P V 2 Replies Last reply
    0
    • R rohit dhamija 0

      Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      Rohit Divas wrote: y = 5++++6*3; :wtf: I would think code that would not even compile. No wonder it is giving you indeterminate results.


      [

      ](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

      I 1 Reply Last reply
      0
      • R rohit dhamija 0

        Dear All, I have a query on following case.Can some body tell the solution for the following: y = 5++++6*3; The answer turns out to be -12 when checked with a C compiler Also, i tried the same on borland delphi 5 and got the answer as 24 How is the processing going on in the above case. Thanks, Regards, Rohit

        V Offline
        V Offline
        Vadim Tabakman
        wrote on last edited by
        #3

        I tried to compile that in some code, and didn't succeed at all. it didn't like the ++ after the 5. I believe it expects a variable. so i'm not sure how you got that to compile :( why are you doing ++++ anyway?

        R 1 Reply Last reply
        0
        • V Vadim Tabakman

          I tried to compile that in some code, and didn't succeed at all. it didn't like the ++ after the 5. I believe it expects a variable. so i'm not sure how you got that to compile :( why are you doing ++++ anyway?

          R Offline
          R Offline
          rohit dhamija 0
          wrote on last edited by
          #4

          yes i did the same and it complied successfully on borland delphi 5 compiler, rohit

          V 1 Reply Last reply
          0
          • R rohit dhamija 0

            yes i did the same and it complied successfully on borland delphi 5 compiler, rohit

            V Offline
            V Offline
            Vadim Tabakman
            wrote on last edited by
            #5

            but you said you got -12 when compiled with the C-compiler. It doesn't even look like valid C-code. If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson

            1 Reply Last reply
            0
            • P PJ Arends

              Rohit Divas wrote: y = 5++++6*3; :wtf: I would think code that would not even compile. No wonder it is giving you indeterminate results.


              [

              ](http://www.canucks.com)"You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" mYkel - 21 Jun '04 Within you lies the power for good - Use it!

              I Offline
              I Offline
              Ian Darling
              wrote on last edited by
              #6

              PJ Arends wrote: I would think code that would not even compile. I agree - it shouldn't - there's a missing operation between the 5++ and the ++6. I suspect someone's posted incorrect code, with a missing or extraneous '+' along the way. Either way, the C++ standard makes no specific guarantees about the order that statement is executed in - a set of operations can be performed in any order if they are within the same sequence point and the rules of precedence don't kick in, IIRC. So we're probably looking at undefined behaviour, hence the different results (watch out for those nasal demons :-))


              Ian Darling The world is a thing of utter inordinate complexity ... that such complexity can arise ... out of such simplicity ... is the most fabulous extraordinary idea ... once you get some kind of inkling of how that might have happened - it's just wonderful ... the opportunity to spend 70 or 80 years of your life in such a universe is time well spent as far as I am concerned - Douglas Adams

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups