Advertisement
Sierra_ONE

The Leap of Year

Oct 8th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | Source Code | 0 0
  1. /*
  2. 10. The Leap of Year
  3. Welcome to Calendars Inc.! As you can already tell, our company is involved in the production of calendars every year. We are in need of a program that would change the landscape of calendar-making forever! Your job is to make a program that would determine whether the year we inputted is a leap year or not.
  4.  
  5. A year is considered a leap year when it is either:
  6. (a) divisible by 4, but not 100 or
  7. (b) divisible by both 4, 100, and 400 at the same time
  8.  
  9. Inputs
  10. 1. The year
  11. */
  12.  
  13.  
  14. #include <stdio.h>
  15.  
  16. int main(){
  17.  
  18.     int year;
  19.  
  20.     printf("Enter the year: ");
  21.     scanf("%d", &year);
  22.  
  23.     if (year % 4 == 0 && year % 100 == 0 && year % 400 == 0){
  24.         printf("%d is a leap year", year);
  25.     }
  26.     else if (year % 4 == 0 && year % 100 != 0){
  27.         printf("%d is a leap year", year);
  28.  
  29.     }
  30.     else {
  31.         printf("%d is not a leap year", year);
  32.     }
  33.  
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement