1. ## One month calendar

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;

}```

2. ok. i figured it out...Not sure if best way of doing it. Any suggestions?

Code:
```#include <stdio.h>

int main (void) {

int i, j, 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 (j = 0; j < dayofweek; j++)
printf ("    ");
for (i = 1; i <= days; i++) {
j++;
printf ("%4d", i);
if (j == 7 || j == 14 || j == 21 || j == 28)
printf ("\n");

}
printf ("\n");
return 0;

}```

3. Code:
`if (j == 7 || j == 14 || j == 21 || j == 28)`
What do those numbers have in common? Can you think of an operator that would help you out with what they have in common?

Quzah.

4. if (j % 7 == 0) or could i use maybe just if (j % 7) ? is that what you mean? I was also hoping for some more input on an easier way to indent other than

Code:
```for (j = 0; j < dayofweek; j++)
printf ("    ");```

5. Originally Posted by danieldcc
if (j % 7 == 0) or could i use maybe just if (j % 7) ?
Well, considering 0 if false and any nonzero is true it would be:
Code:
`if(!(j%7))`
Originally Posted by danieldcc
I was also hoping for some more input on an easier way to indent other than
As for spacing you could try doing tabs, e.g. \t but for console output unless you want to get into goto(x,y) then spaces and tabs are what you have for spacing.

Also, I think your program may be 1 day off when it prints, could be wrong though.

6. cool. tks. Yes it was one off...I modified it, but that's just details...

Tks for the help

7. It gives you an appreciation of the ASCII artists who slaved away when dinosaurs still roamed the earth.....*cough*quzah, Salem,Tater*cough*

8. Originally Posted by AndrewHunter
It gives you an appreciation of the ASCII artists who slaved away when dinosaurs still roamed the earth.....*cough*quzah, Salem,Tater*cough*
Hey, don't put me on that list! I at least had enough sense to wait until after the astroid hit...

http://www.pbs.org/wgbh/evolution/ex.../asteroid.html

9. Originally Posted by CommonTater
Hey, don't put me on that list! I at least had enough sense to wait until after the astroid hit...
So, you never learned COBOL?

BP- Cobol Programmer Dinosaur Mug from Zazzle.com

Tim S.
PS: I never took a class in COBOL; and I hope to never program in it.

10. Originally Posted by stahta01
So, you never learned COBOL?

BP- Cobol Programmer Dinosaur Mug from Zazzle.com

Tim S.
PS: I never took a class in COBOL; and I hope to never program in it.
Nope, no Cobol, Forth or Prolog... and no Flintstone either.

11. Originally Posted by danieldcc
if (j % 7 == 0) or could i use maybe just if (j % 7) ? is that what you mean? I was also hoping for some more input on an easier way to indent other than

Code:
```for (j = 0; j < dayofweek; j++)
printf ("    ");```
Easier way to indent without loop
Code:
`printf("%*s", dayofweek * 4, "");`

12. Originally Posted by AndrewHunter
It gives you an appreciation of the ASCII artists who slaved away when dinosaurs still roamed the earth.....*cough*quzah, Salem,Tater*cough*
Code:
```                                 _.-_
__.'  o "-.
___----""       ,,,'
__--"             _-_ ^^;
____--""  ___         _-\"   `""
..--===-------"""   "(   __-"  ,}
.'_/"\
.'/"  `\`._
"-_c    "  '```
I stole it.

Quzah.