/* File: mycal1.c

   Step 1 in writing my version of the
   calendar program.  This program just
   prints out one months calendar.
*/

void PrintOneMonth(int start, int days) ;

main() {
   int start, days ;

   printf("start =? ") ;
   start = GetInteger() ;
   printf("days =? ") ;
   days = GetInteger() ;

   PrintOneMonth(start, days) ;
}


void PrintOneMonth(int start, int days) {
   int i ;

   /* Indent the first line */
   for (i = 0 ; i < start ; i++) {
      printf("   ") ;
   }

   for (i = 1 ; i <= days ; i++) {
      printf("%3d", i) ;
      /* print newline at end of week */
      if ( (i + start) % 7 == 0 ) {
	 printf("\n") ;
      }
   }

   /* Print newline at end of month
     only if necessary */
   if( (i + start) % 7 != 1)  {
      printf("\n") ;
   }
}

