• icon.Net Online Training In Andhra Pradesh and Telangana
  • icon9010519704

Opening Hours :7AM to 9PM

Learn basis JAVA,Python,.Net from start for beginner

  • Teacher
    Teacher
    Sateesh M
  • Category
    Programaming
  • Review
    • (768 Reviws)
Courses

leap year program

How to check if a year is a leap year in Java
import java.util.Calendar;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Calendar cal = Calendar.getInstance(); 
		int year;
		Scanner s=new Scanner(System.in);
		 System.out.println("Enter Year");
		year =s.nextInt();
		cal.set(Calendar.YEAR, year);  //setting the calendar year
		 int noOfDays = cal.getActualMaximum(Calendar.DAY_OF_YEAR);
		 if(noOfDays>365)
		 {
		 System.out.println("LeapYear");
		 }
		 else
		 {
			 System.out.println("Not LeapYear");
		 }
		
		
	}
}



Output:

Enter Year
2024
LeapYear

How to check if a year is a leap year in Python
Year=int(input("Enter Year : "));
if (((Year % 4 == 0) and (Year % 100 != 0)) or (Year % 400 == 0)):
    print(Year," is a Leap Year.");
else:
    print(Year,"is not a Leap Year.");
                
  
  

                                           
Output:

Enter Year : 2024
2024 is a Leap Year.

How to check if a year is a leap year in C#


class Program
    {
        static void Main(string[] args)
        {
           
                Console.WriteLine("Enter Year : ");
                int Year =Convert.ToInt32(Console.ReadLine());
                if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
                {
                    Console.WriteLine("{0} is a Leap Year.", Year);
                }
                else
                {
                    Console.WriteLine("{0} is not a Leap Year.", Year);
                }
                Console.ReadLine();
        }
    }
   


Output:

Enter Year :
2024
2024 is a Leap Year.

How to check if a year is a leap year in C


#include <stdio.h>

void main() {
  int Year;
  printf("Enter Year : ");
  scanf("%d",&Year) ;
  if (((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0))
    {
    printf("%d is a Leap Year.", Year);
    }
    else
    {
     printf("%d is not a Leap Year.", Year); 
    } 
    
}


Output:

Enter Year : 2024
2024 is a Leap Year.

Course Features

  • Duaration(Core & Advanced) : 90 Hours
  • Leactures : 90
  • Quizzes : 60
  • Interview Questions : 600
  • Important Programs: 300
  • Seminars: 20
Price : 10000 9010519704
Improve Your Knowledge

Daily 10 Minite Reading

Java Training in Hyderabad

Online and Class Room Trainings