...
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023
Programming-for-Output-Problems
October 6, 2023

Programming-for-Output-Problems

Question 8
The following three ‘C’ language statements is equivalent to which single statement?
y=y+1;
z=x+y;
x=x+1
A
z = x + y + 2;
B
z = (x++) + (++y);
C
z = (x++) + (y++);
D
z = (x++) + (++y) + 1;
Question 8 Explanation: 
From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)
Correct Answer: B
Question 8 Explanation: 
From the below statements
y=y+1;
z=x+y;
x=x+1
First statement: “y” value is incremented by 1
Second statement : that incremented value is added to x and stored into “z”
Third statement : “y” value is incremented by 1
z = (x++) + (++y);
X++ post-increment , so it will perform action which is addition and later the value of “x” is incremented .
++y pre-increment , here first value “y” is incremented and updated value is added to value x.
Finally the result will store into z.
The sequence of operations you can find from the below statements
z=x+y; //z = x + (++y)
x=x+1 //z = (x++) + (++y)
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!