VOOZH about

URL: https://www.geeksforgeeks.org/interview-experiences/tcs-coding-practice-question-check-odd-or-even/

⇱ TCS Coding Practice Question | Check Odd or Even - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

TCS Coding Practice Question | Check Odd or Even

Last Updated : 11 Jul, 2025

Given a number, the task is to check if this number is Odd or Even using Command Line Arguments. A number is called even if the number is divisible by 2 and is called odd if it is not divisible by 2. 👁 Image

Examples:

Input: 123
Output: No

Input: 588
Output: Yes

Approach:

  • Since the number is entered as Command line Argument, there is no need for a dedicated input line
  • Extract the input number from the command line argument
  • This extracted number will be in string type.
  • Convert this number into integer type and store it in a variable, say num
  • Check if this number is completely divided by 2
  • If completely divisible, the number is Even
  • If not completely divisible, the number is Odd

Program:

Output:

Time Complexity: O(1)
Auxiliary Space: O(1)

Comment