Advertisement
alkelane7

mohamed saad

Jan 12th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include<iostream.h>
  2. #include<stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7. int d,m,y,year,month,day,i,n;
  8.  
  9. cout<<"Enter the date :";
  10. cin>>d>>m>>y;
  11. if( d>31 || m>12 || (y<1900 || y>=2010) )
  12. {
  13. cout<<"INVALID INPUT";
  14.  
  15. exit(0);
  16. }
  17. year = y-1900;
  18. year = year/4;
  19. year = year+y-1900;
  20. switch(m)
  21. {
  22. case 1:
  23. case 10:
  24. month = 1;
  25. break;
  26. case 2:
  27. case 3:
  28. case 11:
  29. month = 4;
  30. break;
  31. case 7:
  32. case 4:
  33. month = 0;
  34. break;
  35. case 5:
  36. month = 2;
  37. break;
  38. case 6:
  39. month = 5;
  40. break;
  41. case 8:
  42. month = 3;
  43. break;
  44. case 9:
  45. case 12:
  46. month = 6;
  47. break;
  48. }
  49. year = year+month;
  50. year = year+d;
  51. day = year%7;
  52. switch(day)
  53. {
  54. case 0:
  55. cout<<"Day is SATURDAY";
  56. break;
  57. case 1:
  58. cout<<"Day is SUNDAY";
  59. break;
  60. case 2:
  61. cout<<"Day is MONDAY";
  62. break;
  63. case 3:
  64. cout<<"Day is TUESDAY";
  65. break;
  66. case 4:
  67. cout<<"Day is WEDNESDAY";
  68. break;
  69. case 5:
  70. cout<<"Day is THURSDAY";
  71. break;
  72. case 6:
  73. cout<<"Day is FRIDAY";
  74. break;
  75. }
  76.  
  77.  
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement