You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
602 B
R
27 lines
602 B
R
Check Leap Year
|
|
# Program to check if
|
|
# the input year is
|
|
# a leap year or not
|
|
|
|
year = as.integer(readline(prompt="Enter a year: "))
|
|
if((year %% 4) == 0) {
|
|
if((year %% 100) == 0) {
|
|
if((year %% 400) == 0) {
|
|
print(paste(year,"is a leap year"))
|
|
} else {
|
|
print(paste(year,"is not a leap year"))
|
|
}
|
|
} else {
|
|
print(paste(year,"is a leap year"))
|
|
}
|
|
} else {
|
|
print(paste(year,"is not a leap year"))
|
|
}
|
|
Output 1
|
|
|
|
Enter a year: 1900
|
|
[1] "1900 is not a leap year"
|
|
Output 2
|
|
|
|
Enter a year: 2000
|
|
[1] "2000 is a leap year" |