Given a year, check if the year is leap year or not. If yes, the output should be “Leap Year”. Else output should be “Not a Leap Year”. The input should be a positive four digit number. Else, the output should be “Invalid Year”.
Answers
Answered by
1
Answer:
Explanation:
Psuedo code:-
If a year is divisible by 400 -It is leap year. Eg:- 2000
Else If a year is divisible by 100 and NOT 400- It is not leap year Eg:- 1900
Else If a year is divisble by 4 - It is leap year Eg:- 2020
Else it is NOT leap year Eg:- 2019
Program
int main()
{
int year;
if (year%400 == 0)
printf("%d Leap Year\n", year);
else if (year%100 == 0)
printf("%d Not a Leap Year \n", year);
else if (year%4 == 0)
printf("%d Leap Year \n", year);
else
printf("%d Not a Leap Year\n", year);
return 0;
}
Similar questions