TCS Coding Practice Question | Checking Leap Year
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
- 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
Time Complexity: O(1)
Auxiliary Space: O(1)
My Personal Notes arrow_drop_up
Please Login to comment...