Discussion
Consider the following conditional expression
z = (x \gt y) ? x : y;
if x = 2 and y = 8, the value of z is
Answer: B
The value of z is 8, the second option. The conditional expression returns x if the condition (x > y) is true and y otherwise. With x = 2 and y = 8 the condition \(2 \gt 8\) is false, so z takes the value of y, which is 8.
The value 2 would be the result if the condition were true, and 6 and 10 are the difference and the sum of the two numbers, which the expression does not calculate.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development