Hogy-Bear

Q2

Feb 8th, 2018
246
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int birthdayDay(int days, int month, int year);
  4.  
  5. int main(int argc, char const *argv[]) {
  6.  
  7.   birthdayDay(31,1,2018);
  8.  
  9.   return 0;
  10. }
  11.  
  12. int birthdayDay(int days, int month, int year){
  13.  
  14.   if (month == 1){
  15.     year -= 1;
  16.     month = 13;
  17.   }
  18.   if (month == 2){
  19.     year -= 1;
  20.     month = 14;
  21.   }
  22.  
  23.   int k = (year % 100);
  24.   int j = (year / 100);
  25.  
  26.   int h1 = days +
  27.           ( (13 * (month + 1) ) / 5) +
  28.           k +
  29.           ( k / 4 ) +
  30.           ( j / 4 ) +
  31.           ( 5 * j);
  32.  
  33.   int h = h1 % 7;
  34.  
  35.   switch (h) {
  36.     case 0 : printf("You were born on Saturday"); break;
  37.     case 1 : printf("You were born on Sunday"); break;
  38.     case 2 : printf("You were born on Monday"); break;
  39.     case 3 : printf("You were born on Tuesday"); break;
  40.     case 4 : printf("You were born on Wednesday"); break;
  41.     case 5 : printf("You were born on Thursday"); break;
  42.     case 6 : printf("You were born on Friday"); break;
  43.   }
  44.  
  45.   return 0;
  46.  
  47. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment