RE: a=5;c=++a + ++a + ++a;What would be value of c after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;What would be the value of c then?
value will be 24 i.e 8 + 8 +8
why?
because compiler will add them after increment a's value. In this case compiler make two stack like ++a ++a + ++a +
and arithmetic operation will take place after evaluating final value of a and that would be 8 now it time to made some mathematical compiler take the operand i.e 8 and pop an operator '+' from the stack so the expression would be 8 + 8 + 8 24;
RE: a=5;c=++a + ++a + ++a;What would be value of c after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;What would be the value of c then?
RE: a=5;c=++a + ++a + ++a;What would be value of c after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;What would be the value of c then?
RE: a=5;c=++a + ++a + ++a;What would be value of c after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;What would be the value of c then?
For first case value of the C will be 22.For 2nd case it is 15.Consider the first case:C ++a + ++a + ++a;The above calculation will be carried out in the following sequence:1) TempMem (++a + ++a) (pre-increment operator has a preference so before addition value of the “a” is incremented twice and it became 7) so result of the eq1 is 14.2) Again value of the ‘a’ is incremented and now it is 8. Now the remaining part of the instruction will be carried out.3) TempMem TempMem + 8 224) C TempMemConsider the second case:C a++ + a++ + a++;post-increment operator has lower preference so the value of ‘a’ will be incremented thrice after addition but for an addition the value will be unchanged i.e. 5.
RE: a=5;c=++a + ++a + ++a;What would be value of c after this statement and how does it come?If we have the codea=5;c=a++ + a++ + a++;What would be the value of c then?