date - C program on how to check leap year -
How do I get the output of this code:
-
We say When I type in 2012 Production should be on February 29, 2012 a leap year (same thing with other leap year)
-
If I type in 2013, the output should be 2013 a leap year is not.
This is my current code:
Add
& lt; Stdio.h & gt; Int main () {int year; Printf ("Enter a year to check it is a leap year \ n"); Scanf ("% d", and year); If (year% 400 == 0) printf ("% d is a leap year. \", Year); And if (year% 100 == 0) printf ("% d is not a leap year. \ N", year); And if (year% 4 == 0) printf ("% d is a leap year. \ N", year); Other printf ("% d is not a leap year. \ N", year); Return 0; }
What should I set on the day of the week of February 29 in a leap year?
Your question makes me feel like getting it myself and that I started receiving a code that would return one day by inputting a date pattern. In your case if it was a leap year, the date would be 29, 2, and if not, then 28,2 years would be . Represent Sundays here, represent one Monday and so on represent 6 Saturdays.
/ * Includes a program * / # to find a given date day & lt; Stdio.h & gt; Int dayofweek (int d, int m, int y) {static int t [] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; Y - = M & lt; 3; Return (y + y / 4 - y / 100 + y / 400 + t [M-1] + D)% 7; } / * Function to test above function * / int main () {int day = dayofweek (10, 10, 2014); Printf ("% d", days); Return 0; }
If you find any error or difficulty in making changes to the code. Please let me know that I will try to help by adding this code to myself, you can possibly get your needs.
Comments
Post a Comment