saira12tabassum19

Untitled

Jul 1st, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int year;
  6.  
  7. printf("Enter a year to check if it is a leap year\n");
  8. scanf("%d", &year);
  9.  
  10. if (year%400 == 0) // Exactly divisible by 400 e.g. 1600, 2000
  11. printf("%d is a leap year.\n", year);
  12. else if (year%100 == 0) // Exactly divisible by 100 and not by 400 e.g. 1900, 2100
  13. printf("%d isn't a leap year.\n", year);
  14. else if (year%4 == 0) // Exactly divisible by 4 and neither by 100 nor 400 e.g. 2016, 2020
  15. printf("%d is a leap year.\n", year);
  16. else // Not divisible by 4 or 100 or 400 e.g. 2017, 2018, 2019
  17. printf("%d isn't a leap year.\n", year);
  18.  
  19. return 0;
  20. }
Add Comment
Please, Sign In to add comment