Simply use of nested if else property..

Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int year;
cout<<"Program to check Leap year by-Tarun Rawat\n";
cout<<"Enter a year to check : ";
cin>>year;
if ( year%400 == 0)
cout<<year<<" is a leap year\n";
else if ( year%100 == 0)
cout<<year<<" is not a leap year\n";
else if ( year%4 == 0 )
cout<<year<<" is a leap year\n";
else
cout<<year<<" is not a leap year\n";
getch();
}
No comments:
Post a Comment