anyone can write a program to check whether a year is leap year or not | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

anyone can write a program to check whether a year is leap year or not

use if-else statement.👍

14th Jul 2016, 5:00 AM
tabbassum.k
tabbassum.k - avatar
2 Respuestas
0
int year; cout << "Enter Year \n"; cin >> year; if (year%4==0) { cout << "Leap year"; } else { cout << "Not a leap year"; }
14th Jul 2016, 5:57 AM
adarsh shah
adarsh shah - avatar
0
Cited in the wiki article of Leap year: "Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 are not leap years, but the year 2000 is." So... int year; cin >> year; if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { cout << "Leap year"; } else { cout << "Not Leap year"; }
14th Jul 2016, 7:21 AM
this->getName()