Leap year comes after every 4 years. A number is said to be a leap year if the number is divisible by 4 but not by 100 then, it is a leap year. Also, if a number is divisible by 4, 100 and 400 then it is a leap year. If the above conditions does not satisfy then the year is not a leap year.
Example: 2008, 2012 etc.,
We can write the program in different ways, few of them are given below:
Example: 2008, 2012 etc.,
We can write the program in different ways, few of them are given below:
Program to accept a year and check whether the given year is a leap year or not.
Program:
/*C program to finf leap year using if statement */
| # include <stdio.h> |
| Enter a year: 2000 |
The given year is a Leap year
Program to accept a year and check the given year is leap or not by using ternary operator
| # include<stdio.h> |
| Enter a year: 2000 |
No comments:
Post a Comment