Latest News

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;
int main()
{
 int year;
 cout << "Enter year: " << endl;
 cin >> year;
 if(year % 4 == 0 && year % 2 == 0)
 {
  cout << "Leap year: " << endl;
 }
 else{
  cout << "Not leap year: " << endl;
 }
}

// above program also written as
// if(year % 4 == 0)
// cout << "Leap year "  << endl;
// if(year % 100 == 0 && year % 400 == 0)
// cout << "Leap year" << endl;
// else
// cout << "not leap year" << endl;

0 comments:

Post a Comment

If You Have Any Problem While Downloading Comment Below

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Top