write a qbasic program to accept a year and check whether it is a leap year or not
Answers
Answered by
7
if(year%400¦¦year%4==0)
printf("leap year");
}
printf("leap year");
}
Answered by
16
- To check for leap yea there are 3 rules that need to be followed all together:
(Logic for leap year)
- The year should be divisible by 4.
- The year should be divisible by 100.
- The year should be divisible by 400.
- The Q - Basic code for the leap year is:
CLS
INPUT "Enter the Year";year
leap$="No"
IF year MOD 4 = 0 THEN leap$ = "Yes"
IF year MOD 100 = 0 THEN leap$ ="No"
IF year MOD 400 = 0 THEN leap$ = "Yes"
IF leap$ = "Yes" THEN
PRINT year; " is a leap year"
ELSE
PRINT year; " is NOT a leap year"
END IF
Similar questions