TCS Coding Practice Question | Checking Leap Year
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 multiple of 400 and
- if N is multiple of 4 and not multiple of 100
If both of the above conditions are true, then N is a leap year, else not
Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for the language and STL. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up