adplus-dvertising
frame-decoration

Question

Which of the following is another way to rewrite the code snippet given below?

int a = 1, b = 2, c = 0;
if (a < b) c = a;

a.

int a = 1, b = 2, c = 0;
c = a < b ? a : 0;

b.

int a = 1, b = 2, c = 0;
a < b ? c = a : c = 0;

c.

int a = 1, b = 2, c = 0;
a < b ? c = a : c = 0 ? 0 : 0;

d.

int a = 1, b = 2, c = 0;
a < b ? return (c): return (0);

Posted under C# programming

Answer: (a).int a = 1, b = 2, c = 0;
c = a < b ? a : 0;

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following is another way to rewrite the code snippet given below?