Write a C++ program to check whether a given year is leap or not:
- For century year if the given year is completely divided by 400 means reminder will be zero .
- For non century year if it is is not completely divided by 100 and completely divided by 4.
Coding:
#include <iostream>
using namespace std;
int main(){
int year;
cout<<"Enter a year: "<<endl;
cin>>year;
if(year%400==0 || year%100!=0 && year%4==0){
cout<<"This is leap year"<<endl;
}
else{
cout<<"This is not leap year"<<endl;
}
return 0;
}
0 comments:
Post a Comment