Monday, April 22, 2019

Find the Year

  • Problem Description

    Most years have 365 days. However, the time required for the Earth to orbit the Sun is actually slightly more than that. As a result, an extra day, February 29, is included in some years to correct for this difference. Such years are referred to as leap years.

    The rules for determining whether or not a year is a leap year follow:

    Any year that is divisible by 400 is a leap year.
    Of the remaining years, any year that is divisible by 100 is not a leap year.
    Of the remaining years, any year that is divisible by 4 is a leap year.
    All other years are not leap years.

    Write a program that reads a year from the user and displays a message indicating
    whether or not it is a leap year.
  • Test Case 1

    Input (stdin)
    2016

    Expected Output
    Yes
  • Test Case 2

    Input (stdin)
    2001

    Expected Output
    No
Solution

#include <stdio.h>
int main()
{
  int year;
  scanf("%d",&year);
  if(year%4==0)
  {
    printf("Yes");
  }
  else
    printf("No");
  return 0;
}

No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...