#include
#include
void main()
{
int y;
clrscr();
print f ("enter a year");
scan f ("%d",&y)
(y%100==0):((y%400==0)?print f("% d is leap year",y):print f("%d is not leap year",y):((y%4==0)? print f ("d is leap year",y): print f ("%d is leap year",y): print f ("%d is not leap year,y));
getch();
}
There are two steps to find out:
Step-1: If the given year is divisible by 4 but not divisible by 100, then the given year is leap year.
But in some certain cases, this formula is not applicable. However, if the above formula is not success, to confirm your answer, go to step 2.
Step-2: Divide the given year by 400 and if it is divisible by 400, you can confirm that the given year is Leap year. If not divisible by 400, it is not Leap year.
leap yr = ((y%100!=0 && yr %400==0)?1:(yr%4==0)?1:0; leap yr =1; printf ("leap yr"); else printf ("not leap yr");
true
You can use a number of nested "if" commands. The rules are the following: If the year is a multiple of 400, it IS a leap year. Else, if the year is a multiple of 100, it's NOT a leap year. Else, if the year is a multiple of 4, it IS a leap year. Else it's NOT a leap year. In Java, to check for divisibility, you use the "%" operator, which gives you the remainder of a division. For example: if (year % 400 = 0) ... To show results on screen, you use: System.out.println(...)
Great Leap Forward
the Great Leap Forwardthe Great Leap Forward
dono
#include using namespace std;int main(){short numberOfDays = 0;cout > numberOfDays;if (numberOfDays == 365){cout
If the year divides evenly by 4 it's a leap year. If it's a century year it has to divide evenly by 400. 2000 was a leap year. 2100 will not be a leap year.
3900
jete
The Great Leap Forward
Great Leap Forward