VOOZH about

URL: https://www.geeksforgeeks.org/interview-experiences/tcs-coding-practice-question-checking-leap-year/

⇱ TCS Coding Practice Question | Checking Leap Year - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

TCS Coding Practice Question | Checking Leap Year

Last Updated : 11 Jul, 2025

Given a number N, the task is to check if N is a Leap Year or not, using Command Line Arguments. Examples:

Input: N = 2000
Output: Yes
Input: N = 1997
Output: No

👁 Image
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 N
  • Now check for the below conditions:
    • if N is a multiple of 400 and
    • if N is multiple of 4 and not multiple of 100

Program:

Output:


👁 leap

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

Comment