Re: unexpected result



hi anshu
it all compiler depenedent
in lcc-win32 compiler
first the code run on right to left
means i=4*4*2
it give 32 for i
but in turboc compiler it execute code left to right and take big value
among it i.e. 3
so thats y its give 27.


bye
Ankur

ashu wrote:
hi
look at this code

include <stdio.h>
int main(void)
{
int i,j=2;
i=j++ * ++j * j++;
printf("%d %d",i,j);
return 0;
}

acc. to me the values of i & j are 27,5 respectively & rightly so as i


ran this on turbo c++ compiler but if i ran this on lcc-win32 compiler


i got 32 & 5 for i & j respectively.
why this is so

.



Relevant Pages

  • Re: A C tutorial
    ... > (and the associated compiler) is not just a tutorial about ... > programming makes for quite a lot of pages. ... "This tutorial requires the lcc-win32 compiler. ... It uses many extensions to ...
    (comp.lang.c)
  • Re: unexpected result
    ... belongs, after the original post. ... int main ... ran this on turbo c++ compiler but if i ran this on lcc-win32 compiler ...
    (comp.lang.c)
  • Re: Operator overloading in C
    ... 000 lines of code to the original code of the lcc-win32 compiler. ... There were less than one instruction per line, because there were empty lines and comments. ... extensions can be inserted into an existing compiler without ...
    (comp.std.c)
  • Re: Implicit int
    ... lcc-win32 compiler, I can assure you that it is not a big deal, and ... it pays, since it allowed me to implement complex numbers without ... increasing the complexity of the compiler itself! ...
    (comp.std.c)
  • Re: It Pays to Enrich Your C Skills
    ... Check if you can score a perfect 10 (without using a compiler). ... int main{ ... struct bitfield { ... out if it is a negative integer constant or a constant expression ...
    (comp.lang.c.moderated)