Sports GK Questions and Answers 2024 (Latest Updated)

Awards & Honours GK Questions 2024 (Latest Updated)

Question

In the following code segment:

	int z,x=5,y=-10,a=4,b=2;
	z=x++ - --y* b/a;
	

What will be the final value of z?

A 5
B 6
C 10
D 11
Answer & Explanation
Option: [C]

The post increment operator is associated with the variable x. So the current variable is considered i.e. x=5.

The pre increment operator is associated with the variable y. So the value of y decreses by 1. That is y=-11.

Multiplication operator and division operator has the same precedence. So the first one is executed first.

So the expression is:

z=5-(-11)*2/4

=5-(-22/4)

=5-(-5)

=10

Advertisement
Article and Schedule Quiz Start Test!
DOWNLOAD CURRENT AFFAIRS PDF FROM APP
Assam Direct Recruitment Test Series

Computer Science Topics