R
Rob Somers
Hey people
I came across this calendar problem on another board, and so I tried
solving it myself, but to no avail. If you run the program as it is
now, you should see th problem of the spaces being in the wrong spot
on the first line of output after the 'days of the week' line.
here is the code:
#include <stdio.h>
int main(void)
{
int i, n, day;
printf( "Enter number of days in the month:" );
scanf( "%d",&n );
printf( "Enter starting day of the week (1=Sun, 7=Sat):" );
scanf( "%d",&day );
printf( "\n S M T W T F S \n\n" );
for( i = 1; i <= n ; i++ ){
printf( "%3d", i );
if( ( i + day ) % 7 == 0 ){
printf( "\n" );
}
}
printf( "\n\n" );
return 0;
}
I had wanted to solve it just for my own curiosity, but I think it is
beyond me.
I came across this calendar problem on another board, and so I tried
solving it myself, but to no avail. If you run the program as it is
now, you should see th problem of the spaces being in the wrong spot
on the first line of output after the 'days of the week' line.
here is the code:
#include <stdio.h>
int main(void)
{
int i, n, day;
printf( "Enter number of days in the month:" );
scanf( "%d",&n );
printf( "Enter starting day of the week (1=Sun, 7=Sat):" );
scanf( "%d",&day );
printf( "\n S M T W T F S \n\n" );
for( i = 1; i <= n ; i++ ){
printf( "%3d", i );
if( ( i + day ) % 7 == 0 ){
printf( "\n" );
}
}
printf( "\n\n" );
return 0;
}
I had wanted to solve it just for my own curiosity, but I think it is
beyond me.