VOOZH about

URL: https://www.geeksforgeeks.org/interview-experiences/tcs-coding-practice-question-greatest-of-3-numbers/

⇱ TCS Coding Practice Question | Greatest of 3 Numbers - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

TCS Coding Practice Question | Greatest of 3 Numbers

Last Updated : 11 Jul, 2025
Given three numbers, the task is to find the greatest of three numbers using Command Line Arguments. 👁 Image
Examples:
Input: A = 2, B = 8, C = 1
Output: 8

Input: A = 231, B = 4751, C = 75821
Output: 75821
Approach:
  • Since the numbers are entered as Command line Arguments, there is no need for a dedicated input line
  • Extract the input numbers from the command line argument
  • This extracted numbers will be in String type.
  • Convert these numbers into integer type and store it in variables, say A, B and C
  • Find the greatest of the numbers as follows:
    • Check if A is greater than B.
      • If true, then check if A is greater than C.
        • If true, print 'A' as the greatest number.
        • If false, print 'C' as the greatest number.
      • If false, then check if B is greater than C.
        • If true, print 'B' as the greatest number.
        • If false, print 'C' as the greatest number.
  • Print or return the greatest numbers
Program: Output:
Comment