0 votes
754 views
in Programming by (98.9k points)
edited

Write a program in C++, to find if the given year is leap year or not using if else control structure.

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include <iostream>

using namespace std;


int main()

 {

    int year;


    cout << "Enter a year to check: ";

    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;

}



Output::
image


image

Related questions

0 votes
1 answer 1.3k views
0 votes
1 answer 1.5k views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

561 users

...