- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 0124-2383121
Course Introduction
Programs for practice
C++ program asks the user to enter the year to check whether it is a leap year or not, then display it on the screen:
Source Code: Check Leap Year or Not
/* C++ Program - Check Leap Year or Not */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int yr;
cout<<"Enter year :";
cin>>yr;
if((yr%4==0) && (yr%100!=0))
{
cout<<"This is a Leap Year";
}
else if(yr%100==0)
{
cout<<"This is not a Leap Year";
}
else if(yr%400==0)
{
cout<<"This is a Leap Year";
}
else
{
cout<<"This is not a Leap Year";
}
getch();
}
Output
Enter year: 2004
This is a Leap Year