JOIN ADRE 2.0 Telegram Group

Question

Assume that i,j and k are integer variables and their values are 8, 5 and 0 respectively. What will be the values of variables i and k after executing the following expression?

	k=(j>5)?(i<5)?i-j:j-i:k-j;
	i-=(k)?(i)?(j)?:(i):(k);
	

What will be the result of execution?

A -3 and 3
B 3 and -5
C 3 and -3
D -5 and 3
Answer & Explanation
Option: [B]

Given that the values of i,j and k are 8, 5 and 0 respectively. The first statement j>5 is not executed because j=5 and i<5 is also not executed. So the program evaluate k-j, which is, 0-5=-5. So afetre execution of first expression the values are 8, 5 and -5 respectively.

In the second statement the values of k, i are non zero. so it is true for both. So the values of i, j and k are 3, 5 and -5

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