Hello, I'm doing an exercise where i need to print on the screen a one month calendar. My code is mostly done except I don't know how to indent for the first day of the month so it looks in following format (user enter amount of days in month and first day of month)
indent1 2 3 4
4 5 6 7 8 9 10
So I don't know how to start the 1 in the middle there....my code posted below...
Code:#include <stdio.h>
int main (void) {
int i, days, dayofweek;
printf ("Please enter the number of days in the month: ");
scanf ("%d", &days);
printf ("Please enter first day of week (1=sun, 7=sat): ");
scanf ("%d", &dayofweek);
for (i = 1; i <= days; i++) {
printf ("%4d", i);
if (i == 7 || i == 14 || i == 21 || i == 28)
printf ("\n");
}
printf ("\n");
return 0;
}