-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeapYear.c
104 lines (90 loc) · 2.13 KB
/
LeapYear.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// This programs code only forleap year and leap century;
// Name = Ankesh Sharma
// Date = 28th December 2023
// Time = 14:02
#include <stdio.h>
#include <conio.h>
int firstapproach(int year);
int secondapproach(int year);
int thirdapproach(int year);
int main()
{
int year;
printf("Enter the year : ");
scanf("%d", &year);
firstapproach(year);
secondapproach(year);
thirdapproach(year);
}
int firstapproach(int year)
{
if (year % 4 == 0 && year % 400 == 0)
{
printf("Yay the year is leap and century leap");
}
else if (year % 4 == 0 && year % 400 != 0)
{
printf("The year is a leap year but not leap century");
}
else if (year % 4 != 0 && year % 400 == 0)
{
printf("This year is not a leap year but it is a leaap century");
}
else
{
printf("Enter the valid year");
}
}
int secondapproach(int year)
{
printf("\n");
printf("This is for approach two");
printf("\n");
if (year % 4 == 0)
{
if (year % 400 == 0)
{
printf("yay it is a leap year and a leap century");
printf("\n");
}
else
{
printf("It is a leap year but not a leap century");
printf("\n");
}
}
else if (year % 400 == 0 && year % 4 != 0)
{
printf("Yes it is a leap century");
printf("\n");
}
else
{
printf("Please enter valid year");
printf("\n");
}
// printf("\nApproach is working fine");
}
int thirdapproach(int year)
{
printf(("The third approach is here"));
printf("\n");
if(year%4==0 || year%400==0){
if(year%4==0 && year%400==0){
printf("yay it is a leap year and leap century");
}
else if(year%4==0){
printf("\nYes it is a leap year but not leap century");
}
else if(year%400==0){
printf("\nYes it is a leap century but not leap year");
}
else{
printf("\nEnter valid year");
}
}
else{
printf("\nPlease enter valid year");
}
// printf("\n\nApproach is working fine");
}