The user is asked to input the number of days in a month and the first day of the month. Here is the sample output:
Input the number of days in a month: 30
input the first day of the month: 4
0-Sunday
1-Monday
2-Tuesday
3-Wednesday
4-Thursday
5-Friday
6-Saturday
Sun Mon Tues Wed Thurs Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30
This is my sample code, but everytime I enter O in the first day of the month, the alignment is lost. :?:Help!!! :mecry: i tired to fix it several times but i can't!!!
#include<stdio.h>
#define p printf
#define s scanf
int TD,D,x,y=1,E;
main()
{
clrscr();
p("Input Number of days in a month:");
s("%d",&TD);
p("Input the first day of the month:");
s("%d",&D);
p("Sun\tMon\tTues\tWed\tThurs\tFri\tSat\n");
for(x=1;x<=42;x++)
{
if(x<=D)
{
printf("\t");
}
else if(y<=TD)
{
E=7-D;
if(y%7==D)
{
printf("%d\n",y);
}
else
{
printf("%d\t",y);
}
y++;
}}
getch();
}