Computer Science, asked by parkmoch, 10 months ago

c++ if and else programming
Write a program to enter a year check whether leap year or not

Answers

Answered by charlie1505
2

Answer:

#include <iostream>

using namespace std;

int main()

{

int year;

cout << "Enter a year: ";

cin >> year;

if (year % 4 == 0)

{

if (year % 100 == 0)

{

if (year % 400 == 0)

cout << year << " is a leap year.";

else

cout << year << " is not a leap year.";

}

else

cout << year << " is a leap year.";

}

else

cout << year << " is not a leap year.";

return 0;

}

Answered by sougatap57
0

Answer:

#include <iostream>

using namespace std;

int main()

{

/* we have to declare the variable year*/

 int year;

 cout<<"enter the year";

 cin>>year;

/* this is the condition that we will use to check the year is leap year or not */

 if(((year%4==0)&&(year%100!=0))||(year%400==0))

 {

     cout<<"it is a leap year";

 }

 else {

     cout<<"it is not a leap year";

 }

  return 0;

}

output:-

enter the year 2016

it is a leap year

Similar questions