How do you determine the greatest of three numbers logically?

Analytical
Easy
Infosys
91.7K views

A basic comparison problem asking for the maximum of three values. It tests nested conditionals and logic clarity.

Why Interviewers Ask This

This simple question verifies that candidates can write clear and correct conditional logic. It checks if they can handle ties and structure their if-else blocks properly without redundancy.

How to Answer This Question

Explain comparing the first two numbers to find the larger one, then comparing that result with the third number. Alternatively, use a series of if-else statements to check each possibility. Ensure the logic covers all cases including equal values.

Key Points to Cover

  • Pairwise comparison
  • Intermediate result
  • Final selection
  • Handling equality

Sample Answer

To find the greatest of three numbers, I can compare the first two numbers to determine the larger one. Then, I compare this intermediate result with the third number to find the overall maximum. Alternatively, I can use…

Common Mistakes to Avoid

  • Missing a comparison case
  • Incorrect operator precedence
  • Redundant checks

Sound confident on this question in 5 minutes

Answer once and get a 30-second AI critique of your structure, content, and delivery. First attempt is free — no signup needed.

Try it free

Related Interview Questions

Browse all 45 Analytical questionsBrowse all 149 Infosys questions