Write a program to print the calendar of given day.

#include<conio.h>
#include<stdio.h>
int main()
{
int day,i=1,j,c=0;
printf("\nEnter the start day of the month(1-sunday)");
scanf("%d",&day);
printf("\n\nsun\tmon\ttue\twed\tthur\tfri\tsat\n");
printf("\n------------------------------------------------------\n");
printf("\n");
if(day==1)
{
c=1;
}
else if (day == 2)
{
c=2;
printf("\t");
}
else if (day == 3)
{
c=3;
printf("\t\t");
}
else if (day == 4)
{
c=4;
printf("\t\t\t");
}
else if (day == 5)
{
c=5;
printf("\t\t\t\t");
}
else if (day == 6)
{
c=6;
printf("\t\t\t\t\t");
}
else if(day==7)
{
c=7;
printf("\t\t\t\t\t\t");
}
while(i<=30)
{
printf("%d\t",i);
i++;
if(c%7==0)
{
printf("\n");
}
c++;
}
}

No comments:

Post a Comment