Century and leap year

0 votes
asked Sep 30, 2018 by anonymous
Cheak the enter year is leap year and century year

2 Answers

0 votes
answered Sep 30, 2018 by Raju G (370 points)
#include <stdio.h>
 
int main(int argc , char *argv[])
{
  int year;
  year=atoi(argv[1]);
  if ( year%400 == 0)
    printf("\n\n\t\t\t\t\t%d is a leap year.", year);
  else if ( year%100 == 0)
    printf("\n\n\t\t\t\t\t%d isn't a leap year.", year);
  else if ( year%4 == 0 )
    printf("\n\n\t\t\t\t\t%d is a leap year.", year);
  else
    printf("\n\n\t\t\t\t\t%d isn't a leap year.", year);  
  return 0;
}
0 votes
answered Oct 11, 2018 by Lukas (540 points)
edited Oct 11, 2018 by Lukas
#include <stdio.h>

int main()

{

int year;

printf("Please insert a year: ");
    scanf("%i",&year);
    if (year% 4)
    {
        printf("No leap year");
    } else
      if (year% 100 == 0)
        printf("No leap year!");
      else
      printf("Leap year!");

return(0);

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...