Sunday, May 5, 2013

Pro 4 - Write a program to find the given year is leap year or not in C++

ALGORITHM  

1  : Integer lyear

2  : Print''Enter the year''

3  : Input/year

4  ; If   ((lyear %4==0) && (lyear% 100!==0)

            (lyear%400==0)

                 {

             Print lyear ''is a leap year''

else

          Print lyear''is not a leap year''

               }
5  : Stop

========================================================================= 


#include<iostream.h.
#include,conio.h>
void main()
{
clrscr() ;
int lyear;
cout<<"\n Enter the year=";
cin>>lyear;
if((lyear%4==0)&&(lyear%100!=0)||(lyear%400==0)
cout<<lyear<<"is a leap year\n";
       else
cout<<lyear<<"is not a leap year \n";
getch();
}




OUTPUT 


Enter the year= 1996
1996 is a leap year

Enter the year= 2001
2001 is not a leap year
 

No comments:

Post a Comment