C Program to check whether a Date is Valid or not2 min read

In this tutorial, we will write a C program to check date is valid or not. Given the date, month and year, the program finds whether it is valid or not. Although before jumping to the main program, you should have knowledge of the following topics in C programming.

The valid Range for a date, month, and year is 1/1/1800 – 31/12/9999.

Explanation- What does the following program check for:

  • For Date: The date cannot be less than 1 and more than 31.
  • For Month: Month cannot be less than 1 and more than 12
  • For year: The maximum and minimum year is taken before the main program that is less than 1800 and more than 9999.
  • Leap Year: Checks if the year is a leap year or not.
    • If it is a leap year, the February month will have 29 days.
    • If it is not a leap year, the February month will have 28 days.
  • For 30 days month: The months April, June, September, and November cannot have more than 30 days

C Program Date is Valid or Not

Output:

Enter date (DD/MM/YYYY format): 13/06/1998
Date is valid.


MORE

C Program to search an element in an array using Pointers

A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with the size of an array …

C Program to find the sum of the digits of a number using recursion function

This C program calculates the sum of digits of a given number using recursion. Here’s a concise explanation: Function Definition: sumDigits(int n) This function calculates …

C program to find factorial of a number using Ternary operator with Recursion

Recursion refers to the function calling itself directly or in a cycle. Before we begin, you should have the knowledge of following in C Programming: …

C Program to Add Two Numbers Using Call by Reference

The program takes the two numbers from the user and passes the reference to the function where the sum is calculated. You may go through …

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …