[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: [LI] j = ++i * ++i * ++i



Hi

 I think I can do that. When you use ++i, in conjunction with some other
operation then it's incremented first and then used in that operation.
It's ANSI C feature(Sorry could not find better word. Poor English from my
side_:))

So

 int i=2;
 printf("\n%d %d ',++i,++i);

Produces output:  4 3 under gcc.

It can produce output: 3 4 

How? Now it's a question? I know it. Tell you sometime letter.



On Tue, 18 Jan 2000, Aseem Rane wrote:

> 
> if i is initialized to say 3,
> 
> what will be the value of j, where
> 
> j = ++i * ++i * ++i;
> 
> on solaris 
> using cc answer is 
> j = 6 * 6 * 6;
> 
> useing gcc answer is
> j = 4 * 5 * 6;
> 
> 
> but on linux (RH6.1 PCQ)
> 
> j = 5 * 5 * 6;

How can this happen anyway? I don't get it.

 Bye
  Shridhar


> 
> can anybody explain logic behind j's value on linux???
> 
> bye
> aseem
> 

--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.