retagged by
4,887 views

4 Answers

Best answer
11 votes
11 votes
Here y is incrementing before calculation of z and x incrementing after calculation of z

So y will be preincrement and x is postincrement

So Ans B)
selected by
3 votes
3 votes

Just take x,y,z =1 and apply to all the options .

B and C will give correct answer

But as Y is incremented before X, and we are only using updated value of Y to find value of Z, so we will only choose B)

Answer is B).

0 votes
0 votes
as u can see here the increment of y is written before z expression so preincrement ,

and then x is incremented after z expression so post increment

thats why ans will be x= ++y + x++
0 votes
0 votes

option B is right answer  (Upvote it if it is helpfull) 

B. z = (x++) + (++y);

here we need to perform stack evaluation 

so for the stack evalution the steps are

  1. pre increment/ decrement
  2. substitute the value 
  3. Assign the values
  4. post increment/ decrement

let x=1 y=2 

then by,

y=y+1; → y = 2 + 1 = 3 ;

z=x+y; → z = 1 + 3 = 4 ;

x=x+1; → x = 1 + 1 = 2 ;

after operations x=2,y=3,z=4………………….….,,,,….(1)

option B : x=1,y=2,z=3;

z = (x++) + (++y);

z = 1 + 3

z = 4

after assignment of value in z 

the value of y = 3 , x= 2  ,z=4  ………………………………...(2)

from eqn (1) & (2),

x,y,z values  are same

 

Answer:

Related questions

7 votes
7 votes
9 answers
1
pooja14 asked Jun 22, 2016
8,038 views
What is the output of the following C program? #include<stdio.h #define SQR(x) (x*x) int main() { int a; int b=4; a=SQR(b+2); printf("%d\n",a); return 0; }14361820
6 votes
6 votes
3 answers
2
Sourabh Kumar asked Jun 22, 2016
5,563 views
How many lines of output does the following C code produce?#include<stdio.h float i=2.0; float j=1.0; float sum = 0.0; main() { while (i/j 0.001) { j+=j; sum=sum+(i/j); ...
8 votes
8 votes
7 answers
3
3 votes
3 votes
2 answers
4
ajit asked Sep 23, 2015
5,115 views
Which of the following is true with respect to Reference?A reference can never be NULLA reference needs an explicit dereferencing mechanismA reference can be reassigned a...