Computer Science, asked by rajdeep123344, 1 year ago

write a qbasic program to accept a year and check whether it is a leap year or not

Answers

Answered by naina268
7
if(year%400¦¦year%4==0)

printf("leap year");
}
Answered by Anonymous
16
  • To check for leap yea there are 3 rules that need to be followed all together:

(Logic for leap year)

  1. The year should be divisible by 4.
  2. The year should be divisible by 100.
  3. 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