Write a C program to check date is valid or not (2 Methods)
belongs to collection: C Advance Solved Programs – C Programming
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
belongs to collection: C Advance Solved Programs – C Programming
total answers (1)
The program given below first accepts a date from the keyboard, determines whether it is valid or not using the algorithm given above and then prints an appropriate message.
Let us use variables dd,mm and yy (all of type int)to represent the day, month and year in a given date.
The given date is valid only if year (yy)is non-zero, month (mm)is in the range 1 to 12 and day of month (dd) is in the range 1 to mdays, the number of days in a given month mm.
Observe that the %d format Specifiers in the scanf format string are separated by ‘/’ characters as “%d/%d/%d”.
Such non-format characters in the format string of the scanf statement must be entered by the user at the indicated position. Thus, the user must enter the date in the format dd/mm/yyyy.
Below is the source code of the C program to check date is valid or not which is successfully compiled and run on the windows system.The Output of the program is shown below.
1 . SOURCE CODE : :
OUTPUT : :
2. Write a C program to check date is valid or not.This program will read date from user and validate whether entered date is correct or not with checking of leap year.
LOGIC : :
Below is the source code of the C program to check date is valid or not which is successfully compiled and run on the windows system.The Output of the program is shown below.
2 . SOURCE CODE : :
OUTPUT : :
need an explanation for this answer? contact us directly to get an explanation for this answer