Tuesday, 24 December 2013

Any year is entered through the keyboard, write a program to determine whether the year is leap or not. Use the logical operators && and ||.

 #include<iostream>
 using namespace std;
#include<conio.h>
int main()
{
  int year;
 
  cout<<"enter any year : ";
  cin>>year;
  if((year%4==0&&year%100!=0)||year%400==0)
  {
    cout<<year<<" is a Leap Year.";
  }
  else
  {
    cout<<year<< "is not a Leap Year";
  }
  getch();
  return 0;
}

No comments:

Post a Comment