java program for leap year
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
System.out.println(“Enter a number”);
int n = scn.nextInt();
if((n%400 == 0) || (n%4 == 0 && n%100 !=0)){
System.out.println(“leap year”);
}else{
System.out.println(“not leap year”);
}
}
}
int main()
{
int year;
scanf(“%d”,&year);
if((year%400==0)||(year%4==0 && year%100!=0))
printf(“%d is leap year”,year);
else
printf(“%d is not leap year”,year);
return 0;
}
// Online C compiler to run C program online
#include
int main() {
int year;
printf(“enter a year :”);
scanf(“%d”,&year);
if(year%4==0){
if(year%100==0 && year%400!=0){
printf(“%d year is not a leap year”,year);
}
else{
printf(“%d year is a leap year”,year);
}
}
else{
printf(“%d year is not a leap year”,year);
}
public class leapYear {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n%4==0) {
if(n%100==0) {
if(n%400==0) {
System.out.println(“leap year”);
}else {
System.out.println(” not leap year”);
year = int(input())
if((year%4==0 or year%100==0) or(year%100==0 and year %400 == 0)):
print(year, “is a leap year”)
else:
print(year,”is not a leap year”)
n=int(input(“Enter the year:\n”))
if(n%4==0):
if(n%100==0):
if(n%400==0):
print(f”{n} is a Leap year”)
else:
print(f”{n} is not a Leap year”)
else:
print(f”{n} is a Leap year”)
else:
print(f”{n} is not a Leap year”)
java program for leap year
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scn = new Scanner(System.in);
System.out.println(“Enter a number”);
int n = scn.nextInt();
if((n%400 == 0) || (n%4 == 0 && n%100 !=0)){
System.out.println(“leap year”);
}else{
System.out.println(“not leap year”);
}
}
}
n=int(input())
if(n%400==0):
print(n,’is LEAP YEAR’)
else:
if(n%4==0):
if(n%100!=0):
print(n,’is LEAP YEAR’)
else:
print(n,’is not LEAP YEAR’)
else:
print(n,’is not LEAP YEAR’)
int main()
{
int year;
scanf(“%d”,&year);
if((year%400==0)||(year%4==0 && year%100!=0))
printf(“%d is leap year”,year);
else
printf(“%d is not leap year”,year);
return 0;
}
// Online C compiler to run C program online
#include
int main() {
int year;
printf(“enter a year :”);
scanf(“%d”,&year);
if(year%4==0){
if(year%100==0 && year%400!=0){
printf(“%d year is not a leap year”,year);
}
else{
printf(“%d year is a leap year”,year);
}
}
else{
printf(“%d year is not a leap year”,year);
}
return 0;
}
#include
int main()
{
int n;
printf(“enter year”);
scanf(“%d”,&n);
if(n%4==0 && n%100!=0)
{
printf(“leap year”);
}
else if (n%400==0)
{
printf(“leap year”);
}
else
{
printf(“Not a leap year”);
}
return 0;
}
public class leapYear {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n%4==0) {
if(n%100==0) {
if(n%400==0) {
System.out.println(“leap year”);
}else {
System.out.println(” not leap year”);
}
}else {
System.out.println(“leapyear”);
}
}else {
System.out.println(“not leap year”);
}
}
}
year = int(input())
if((year%4==0 or year%100==0) or(year%100==0 and year %400 == 0)):
print(year, “is a leap year”)
else:
print(year,”is not a leap year”)
#python
n=int(input(“Enter the year:\n”))
if(n%4==0):
if(n%100==0):
if(n%400==0):
print(f”{n} is a Leap year”)
else:
print(f”{n} is not a Leap year”)
else:
print(f”{n} is a Leap year”)
else:
print(f”{n} is not a Leap year”)