# Find Day from Day in C without Using Function

## Some Calendar Information

The time it takes for Earth to complete one orbit of the Sun is one year. It comes close to being 365.25 days. Therefore, if 365 days are regarded as a year, 4 years total have 1 day remaining. This results in a leap year, which has 366 days and happens once every four years. Every four-digit year, such as 0004, 0008, and so on, is a leap year starting with the year 0001. However, 365.25 is also an approximation. These results in anomalies occurring every 100 or 400 years, i.e., the years 0100, 0200, and 0300 are not leap years, but the year 0400 is.

An whole year has 12 months. They have the following lengths (Number of Days):

February 28 (if it's a non-leap year) and March 29 (Leap Year)

March 31 through April 30 through May 31 through June 30 through August 31 through September 30 through December 31

The TOTAL is thus 365 (Non-Leap Year) and 366. (Leap Year).

We discovered a truth that is 01-01-0001 by moving backward. i.e., Monday, January 1st, 0001. This serves as the program's foundation. Additionally, we employ a variable named day value, whose values are 0, 1, 2, 3, 4, or 6 for Monday, Tuesday, Thursday, Friday, Saturday, and Sunday, respectively.

Output:

```?nter a valid date ( dd / mm / yyyy ) : 05/07/2022

The day is : Tuesday
..................................................
Process executed in 1.22 seconds
Press any key to continue.
```

Explanation

A total of 12 distinct integers can be kept in the array month[12], which is of the type integer. Additionally initialized at declaration time is this array. Each value in this array indicates how many days there are in a specific month, for example, the first value, 31, indicates that January has 31 days. Char [7] [10] - This is a different array from the month [12] array mentioned before since it is a multidimensional array of the type character. This array can hold up to seven items, and each value's length must be between nine and ten. The days, such as Sunday, Monday, and so on, are represented by this array. These integers are used to record the day, month, and year that the user has supplied. Other integers used for intermediate computations include I, r, and s. Here, we're using the string copy function strcpy from the C language, rather than initializing the char[7][10] array at the time of declaration like we did with the month[12] array ().

The strcpy() method is used to initialize week[7][10]. Now, we request preformatted input from the user. When the user inputs the date in the format dd/mm/yyyy, all three values are immediately stored in their respective variables since we separated each integer within scanf() by a "/".

Then if statement then determines whether or not the year the user supplied is a leap year. The number of days in the month of February is set to 29 if the year is a leap year by month [1] = 29;