Date
Lesson 9 of 25 in Coddy's Coding Problems: Volume 2 course.
A given date can be valid or not. We need to look out if the month is between 1 and 12, if it's a leap year, (leap year is every year that is divisible with 400, or is divisible with 4 but not 100), and if the days of the month are accurate, 30 and 31.
Challenge
EasyWrite a program that for a given date outputs VALID if it's an existing date, and NOT VALID otherwise
Input
1 6 1992
Output
VALID
Input
30 2 2004
Output
NOT VALID
Explanation
The first date is valid, but the second date is not valid because February never has 30 days.
Try it yourself
#include <stdio.h>
int main() {
// Write code here
return 0;
}
All lessons in Coding Problems: Volume 2
1Course Introduction
Introduction