Check if date is valid
Submissions: 1380   Accuracy:


  Difficulty: Basic   Marks: 1

Given a date, the task is to check if it is valid or not. It may be assumed that the given date is in range from 01/01/1800 to 31/12/9999 and any date not within this range will also be considered invalid.

Examples :

Input : d = 10, m = 12, y = 2000
Output : 1
The given date 10/12/2000 is valid

Input  : d = 30, m = 2, y = 2000
Output : 0
The given date 30/2/2000 is invalid. The
February month cannot have 30 as day.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains 3 space separated integers d, m, y denoting the day, month and the year respectively.

For each test case in a new line print 1 if the date is a valid date else print 0.

1 <= T <= 100
1 <=d, m, y<=10000


10 12 2000
30 2 2000

** For More Input/Output Examples Use 'Expected Output' option **

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.