JOIN ADRE 2.0 Telegram Group

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

ADRE 2.0 FULL LENGTH MOCK TEST

Take Mock Tests

Missiles Mock Test Start Test!
SSC MTS Mock Test Start Test
IBPS CLERK MOCK TEST Start Test
SSC MTS 2022 JULY 26 Shift 1 (ENGLISH) Start Test!
SSC GD Previous Year Paper 2021 Nov 17 Shift - I (Hindi) Start Test!
SSC CGL Tier - 1 PYP 2022 April 21 Shift- 1 (ENGLISH) Start Test!
MPSC PAPER I MOCK TEST 1 (ENGLISH) Start Test!
IB Security Assistant Mock test 1 (english) Start Test!
UP POLICE CONSTABLE MOCK TEST 1 Start Test!
DELHI POLICE CONSTABLE MOCK TEST 1 (HINDI) Start Test!
Advertisement
Assam Direct Recruitment Test Series