fork(4) download
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main()
  4. {
  5. int h,q,m,k,j,day,month,year;
  6. printf("Enter the date (dd/mm/yyyy)\n");
  7. scanf("%i/%i/%i",&day,&month,&year);
  8. if(month == 1)
  9. {
  10. month = 13;
  11. year--;
  12. }
  13. if (month == 2)
  14. {
  15. month = 14;
  16. year--;
  17. }
  18. q = day;
  19. m = month;
  20. k = year % 100;
  21. j = year / 100;
  22. h = q + 13*(m+1)/5 + k + k/4 + j/4 + 5*j;
  23. h = h % 7;
  24. switch(h)
  25. {
  26. case 0 : printf("Saturday.\n"); break;
  27. case 1 : printf("Sunday.\n"); break;
  28. case 2 : printf("Monday. \n"); break;
  29. case 3 : printf("Tuesday. \n"); break;
  30. case 4 : printf("Wednesday. \n"); break;
  31. case 5 : printf("Thurday. \n"); break;
  32. case 6 : printf("Friday. \n"); break;
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 1836KB
stdin
28/02/2013
stdout
Enter the date (dd/mm/yyyy)
Thurday.