Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int calendar (int daynum, int startday);
- int main ()
- {
- int done, x, y;
- done = 0;
- x = 0;
- y = 0;
- while (done != 1)
- {
- printf("Enter number of days in month: ");
- scanf("%d", &x);
- if (x == 0)
- { done = 1;
- }
- else if (x < 28)
- { printf("Wrong input for the number of days.\n");
- }
- else if (x > 31)
- { printf("Wrong input for the number of days.\n");
- }
- else
- { printf("Enter the starting day of the week (1=Sun, 7=Sat): ");
- scanf("%d", &y);
- calendar(x, y);
- }
- }
- return 0;
- }
- int calendar (int daynum, int startday)
- {
- int nice, n1;
- printf("Sun Mon Tue Wed Thu Fri Sat \n");
- for(n1 = startday; n1 >= 0; n1--)
- {
- printf(" ");
- }
- for(n1 = 1; n1 <= daynum; n1++)
- {
- printf(" %d", n1);
- }
- return nice;
- }
Add Comment
Please, Sign In to add comment