Computer Science, asked by AnugrahVarghese9199, 10 months ago

Lucy is celebrating her 15th birthday. Her father promised her that he will buy her a new computer on her birthday if she solves the question asked by him. He asks Lucy to find out whether the year on which she was born is a leap year or not. Help her to solve this puzzle so that she celebrates her birthday happily. If her birth year is 2016 and it is a leap year display ""2016 is a leap year."" Else display ""2016 is not a leap year.""

Answers

Answered by madhavan07
3

Answer:

Actually this code can be implemented in any programing language.

i am giving the algorithm:

Get the year as input and store it in a variable (say x).

Now if x % 4 equal to 0

print x is a leap year

else print x is not a leap year

If you tell me the programming language, i shall give the code

Explanation:

The leap years are perfectly divisible by 4

so I use '%' symbol. the % symbol returns the remainder.

so if it is a leap year, then if you divide by 4 the remainder is zero.

so if x % 4 equal to zero then it is a leap year

Answered by kiruthikavjshankar
13

Answer:

#include<iostream>

using namespace std;

int main()

{

 //Type your code here.

 int y;

 cin>>y;

 (y%4==0)?cout<<y<<" is a leap year":cout<<y<<" is not a leap year";

}

Explanation:

When the year is a multiple of 4 we can print it is a leap year(Only in this case).

Similar questions