382 views
4 votes
Consider the following code segment in which the int variables a and b have been properly declared and initialized.

if (a < b) { a++; } else
if (b < a) { b++; } else
{ a++; b++; }

User Zoilo
by
5.1k points

1 Answer

1 vote

Answer:

a and b should both be declared and initialized

Step-by-step explanation:

The code checks

i - if a is less than b; a should be incremented by 1

ii - if b is less than a; b should be incremented by 1

iii - if none of the two conditions were met; both a and b get incremented by 1

User Kowsalya
by
6.0k points