Unable to determine output

Hi,

I am unable to trace the behaviour of my TC compiler when it calculates the following exp :

z=--i*2+--i+--(--i);

z=--i+--(--i)
etc.

Please explain how it calculates these exp.Please give a proper answer I am uninterested in answer like the behaviour is compiler dependent.
Thanks.

Comments

  • [b][red]This message was edited by stober at 2004-7-31 0:47:20[/red][/b][hr]
    : Hi,
    :
    : I am unable to trace the behaviour of my TC compiler when it calculates the following exp :
    :
    : z=--i*2+--i+--(--i);
    :
    : z=--i+--(--i)
    : etc.
    :
    : Please explain how it calculates these exp.Please give a proper answer I am uninterested in answer like the behaviour is compiler dependent.
    : Thanks.
    :
    [blue]That won't compile -- so TC can't calculate the expression.[/blue]


  • : [b][red]This message was edited by stober at 2004-7-31 0:47:20[/red][/b][hr]
    : : Hi,
    : :
    : : I am unable to trace the behaviour of my TC compiler when it calculates the following exp :
    : :
    : : z=--i*2+--i+--(--i);
    : :
    : : z=--i+--(--i)
    : : etc.
    : :
    : : Please explain how it calculates these exp.Please give a proper answer I am uninterested in answer like the behaviour is compiler dependent.

    : : Thanks.
    : :
    : [blue]That won't compile -- so TC can't calculate the expression.[/blue]
    :
    :
    :

    The code written above was actually
    int i=20;
    int z;
    z=(--i)*2+(--i)+(--(--i));

    z=(--i)+(--(--i));

    It is in compilable state.
    Please reply now.

  • [b][red]This message was edited by stober at 2004-8-7 6:25:59[/red][/b][hr]
    :
    : The code written above was actually
    : int i=20;
    : int z;
    : z=(--i)*2+(--i)+(--(--i));
    :
    : z=(--i)+(--(--i));
    :
    : It is in compilable state.
    : Please reply now.
    :
    :

    [blue]That still won't compile. Why don't you compile it yourself before posting?

    This is not valid[/blue]
    [code]
    (--(--i)) [red]<<< invalid syntax[/red]
    [/code]







  • : Please explain how it calculates these exp.Please give a proper answer I am uninterested in answer like the behaviour is compiler dependent.
    : Thanks.

    It shouldn't matter how it's evaluated since you shouldn't be writing such evil expressions in the first place!
  • : [b][red]This message was edited by stober at 2004-8-7 6:25:59[/red][/b][hr]
    : :
    : : The code written above was actually
    : : int i=20;
    : : int z;
    : : z=(--i)*2+(--i)+(--(--i));
    : :
    : : z=(--i)+(--(--i));
    : :
    : : It is in compilable state.
    : : Please reply now.
    : :
    Whether it compiles or not, why would you want to unless you are trying to confuse yourself.


  • My guess is that it's an exercise in a book or tutorial to teach operator presidence. Otherwise useless exercise.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories