ara1123

Untitled

Oct 4th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int calendar (int daynum, int startday);
  5.  
  6. int main ()
  7. {
  8.  
  9. int done, x, y;
  10. done = 0;
  11. x = 0;
  12. y = 0;
  13.  
  14. while (done != 1)
  15. {
  16. printf("Enter number of days in month: ");
  17. scanf("%d", &x);
  18.  
  19. if (x == 0)
  20. { done = 1;
  21. }
  22. else if (x < 28)
  23. { printf("Wrong input for the number of days.\n");
  24. }
  25. else if (x > 31)
  26. { printf("Wrong input for the number of days.\n");
  27. }
  28. else
  29. { printf("Enter the starting day of the week (1=Sun, 7=Sat): ");
  30. scanf("%d", &y);
  31.  
  32. calendar(x, y);
  33. }
  34. }
  35.  
  36.  
  37. return 0;
  38. }
  39.  
  40. int calendar (int daynum, int startday)
  41. {
  42. int nice, n1;
  43.  
  44. printf("Sun Mon Tue Wed Thu Fri Sat \n");
  45.  
  46. for(n1 = startday; n1 >= 0; n1--)
  47. {
  48. printf(" ");
  49.  
  50. }
  51.  
  52. for(n1 = 1; n1 <= daynum; n1++)
  53. {
  54. printf(" %d", n1);
  55. }
  56.  
  57. return nice;
  58. }
Add Comment
Please, Sign In to add comment