944,161 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 19949
  • C RSS
Oct 4th, 2007
-3

Calendar program

Expand Post »
Can u help me in my assignment in making a calendar program using turbo c.
I have made a few functions but im now stuck. What will I do with this?

User is asked to input year and month, then the out put will be the year and the Calendar of the month inputed...

pls help me.. asap





#include<stdio.h>

void printMonth (int startDay, int days);

int main (void)
{
printfMonth(2,29);
return 0;
}

/*======printMonth===========*/

void printMonth (int startDay, int days)

{
int weekDay;
int dayCount = 0;
{
printf("Sun Mon Tue Wed Thu Fri Sat\n");
printf("--- --- --- --- --- --- ---\n");

for (weekDay= 0; weekDay < startDay; weekDay++)
{printf(" ");}

for (int dayCount = 1; dayCount <= days; dayCount++)
{
if (weekDay > 6)
{
printf("\n");
weekDay = 1;
}
else
weekDay++;
printf("%3d", daycount);
}
printf("\n--- --- --- --- --- --- ---\n");
return;
}}
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
janxxx is offline Offline
2 posts
since Oct 2007
Oct 4th, 2007
0

Re: Calendar program

i hope i can recieve a reply today... plssss
Reputation Points: 10
Solved Threads: 0
Newbie Poster
janxxx is offline Offline
2 posts
since Oct 2007
Oct 4th, 2007
0

Re: Calendar program

First of all, read this. Then explain what your problem is, don't make us try to guess. And be patient. We all have lives and don't live here at DaniWeb -- 13 minutes is not an appropriate length of time to get demanding.
Moderator
Reputation Points: 3281
Solved Threads: 896
Posting Sage
WaltP is offline Offline
7,749 posts
since May 2006
Oct 5th, 2007
0

Re: Calendar program

what to do if folder options is not there in yhe taskbar
vij
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vij is offline Offline
1 posts
since Oct 2007
Oct 8th, 2007
0

Re: Calendar program

Click to Expand / Collapse  Quote originally posted by janxxx ...
Can u help me in my assignment in making a calendar program using turbo c.
I have made a few functions but im now stuck. What will I do with this?

User is asked to input year and month, then the out put will be the year and the Calendar of the month inputed...

pls help me.. asap





#include<stdio.h>

void printMonth (int startDay, int days);

int main (void)
{
printfMonth(2,29);
return 0;
}

/*======printMonth===========*/

void printMonth (int startDay, int days)

{
int weekDay;
int dayCount = 0;
{
printf("Sun Mon Tue Wed Thu Fri Sat\n");
printf("--- --- --- --- --- --- ---\n");

for (weekDay= 0; weekDay < startDay; weekDay++)
{printf(" ");}

for (int dayCount = 1; dayCount <= days; dayCount++)
{
if (weekDay > 6)
{
printf("\n");
weekDay = 1;
}
else
weekDay++;
printf("%3d", daycount);
}
printf("\n--- --- --- --- --- --- ---\n");
return;
}}
try this if it can help its a calendar program.


#include <stdio.h>
#include <conio.h>
int a,b,c;
int main()
{
clrscr();
printf("Enter Number:");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\t\t\tJanuary 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t1\t2\t3\t4\t5\t6\n\n");
printf("\t7\t8\t9\t10\t11\t12\t13\n\n");
printf("\t14\t15\t16\t17\t18\t19\t20\n\n");
printf("\t21\t22\t23\t24\t25\t26\t27\n\n");
printf("\t28\t29\t30\t31\n\n");break;

case 2:
printf("\t\t\tFebruary 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t\t1\t2\t3\n\n");
printf("\t4\t5\t6\t7\t6\t9\t10\n\n");
printf("\t11\t12\t13\t14\t15\t16\t17\n\n");
printf("\t18\t19\t20\t21\t22\t23\t24\n\n");
printf("\t25\t26\t27\t28\n\n");break;

case 3:
printf("\t\t\tMarch 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}printf("\t\t\t\t\t1\t2\t3\n\n");
printf("\t4\t5\t6\t7\t6\t9\t10\n\n");
printf("\t11\t12\t13\t14\t15\t16\t17\n\n");
printf("\t18\t19\t20\t21\t22\t23\t24\n\n");
printf("\t25\t26\t27\t28\t29\t30\t31\n\n");
break;
case 4:
printf("\t\t\tApril 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t1\t2\t3\t4\t5\t6\t7\n\n");
printf("\t8\t9\t10\t11\t12\t13\t14\n\n");
printf("\t15\t16\t17\t18\t19\t20\t21\n\n");
printf("\t22\t23\t24\t25\t26\t27\t28\n\n");
printf("\t29\t30\n\n");break;

case 5:
printf("\t\t\tMay 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t1\t2\t3\t4\t5\n\n");
printf("\t6\t7\t8\t9\t10\t11\t12\n\n");
printf("\t13\t14\t15\t16\t17\t18\t19\n\n");
printf("\t20\t21\t22\t23\t24\t25\t26\n\n");
printf("\t27\t28\t29\t30\n\n");break;

case 6:
printf("\t\t\tJune 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t\t1\t2\t3\n\n");
printf("\t3\t4\t5\t6\t7\t8\t9\n\n");
printf("\t10\t11\t12\t13\t14\t15\t16\n\n");
printf("\t17\t18\t19\t20\t21\t22\t23\n\n");
printf("\t24\t25\t26\t27\t28\t29\t30\n\n");break;

case 7:
printf("\t\t\tJuly 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t1\t2\t3\t4\t5\t6\t7\n\n");
printf("\t8\t9\t10\t11\t12\t13\t14\n\n");
printf("\t15\t16\t17\t18\t19\t20\t21\n\n");
printf("\t22\t23\t24\t25\t26\t27\t28\n\n");
printf("\t29\t30\t31\n\n");break;

case 8:
printf("\t\t\tAugust 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t1\t2\t3\t4\n\n");
printf("\t5\t6\t7\t8\t9\t10\t11\n\n");
printf("\t12\t13\t14\t15\t16\t17\t18\n\n");
printf("\t19\t20\t21\t22\t23\t24\t25\n\n");
printf("\t26\t27\t28\t29\t30\t31\n\n");break;

case 9:
printf("\t\t\tSeptember 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t\t\t\t1\n\n");
printf("\t2\t3\t4\t5\t6\t7\t8\n\n");
printf("\t9\t10\t11\t12\t13\t14\t15\n\n");
printf("\t16\t17\t18\t19\t20\t21\t22\n\n");
printf("\t23\t24\t25\t26\t27\t28\t29\n\n");
printf("\t30"); break;

case 10:
printf("\t\t\tOctober 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t1\t2\t3\t4\t5\t6\n\n");
printf("\t7\t8\t9\t10\t11\t12\t13\n\n");
printf("\t14\t15\t16\t17\t18\t19\t20\n\n");
printf("\t21\t22\t23\t24\t25\t26\t27\n\n");
printf("\t28\t29\t30\t31\n\n");break;

case 11:
printf("\t\t\tNovember 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t\t1\t2\t3\n\n");
printf("\t4\t5\t6\t7\t6\t9\t10\n\n");
printf("\t11\t12\t13\t14\t15\t16\t17\n\n");
printf("\t18\t19\t20\t21\t22\t23\t24\n\n");
printf("\t25\t26\t27\t28\t29\t29\t30\n\n");break;

case 12:
printf("\t\t\tDecember 2007");
printf("\n\t");
for(b=1;b<=51; b++)
{
if(b==51)
printf("=\n");
else
printf("=");
gotoxy(9,3); printf("Sun\tMon\tTue\tWed\tThu\tFri\tSat\n\t");
for(b=1;b<=51;b++)
{
if(b==51)
printf("=\n");
else
printf("=");
}
printf("\t\t\t\t\t\t\t1\n\n");
printf("\t2\t3\t4\t5\t6\t7\t8\n\n");
printf("\t9\t10\t11\t12\t13\t14\t15\n\n");
printf("\t16\t17\t18\t19\t20\t21\t22\n\n");
printf("\t23\t24\t25\t26\t27\t28\t29\n\n");
printf("\t30");
break;
} } } } } } } } } } } }
getch();
return 0;
}}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
restrooms is offline Offline
10 posts
since Oct 2007
Oct 8th, 2007
0

Re: Calendar program

What a horrible unformatted mess that is, which is only good for a DOS compiler for one specific year.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005
Nov 15th, 2007
0

Re: Calendar program.... Fromme

this pogram will give u th day othe dd/mm/yy or the dates of day/mm/yy
try... its simple program... n reply to
vivek.es2386@gmail.com

#include<stdio.h>
#include<conio.h>
#define leap(y) ((y%4==0)&&(y%400!=0))

void find_day(int o)
{
switch(o)
{
case 0:printf("sunday");
break;
case 1:printf("monday");
break;
case 2:printf("tuesday");
break;
case 3:printf("wednesday");
break;
case 4:printf("thursday");
break;
case 5:printf("friday");
break;
default:printf("saturday");
break;
}
}


void main()
{
int i,j,p,dd,dy,mm,xy,yy,flag,oy,od=0,leap,m,n;
int year[]={31,28,31,30,31,30,31,31,30,31,30,31};
char ch;
clrscr();

printf(" enter '1' if ur entering dd/mm/yy or");
printf("\n enter '2' if ur entering day/mm/yy:");
ch=getche();
clrscr();
if(ch=='1')
{
printf("\n enter date:");
scanf("%d",&dd);
printf("\n enter month:");
scanf("%d",&mm);
printf("\n enter year:");
scanf("%d",&yy);
flag=1;
}

else if(ch=='2')
{
printf("\n enter day:");
printf("enter 0-Sun, 1-Mon, 2-Tue, 3-wed, 4-Thurs, 5-Fri, 6-sat:");
scanf("%d",&dy);
printf("\n enter month:");
scanf("%d",&mm);
printf("\n enter year:");
scanf("%d",&yy);
flag=0;
}
else
printf("enter invalid input");

xy=yy-1;
m=xy/400;
n=xy-400*m;

if(n>100)
{
p=n/100;
od=p*5;
n=n%100;
}

leap=n/4;
oy=n-leap;
od=od+leap*2+oy;
od=od%7;

printf("m=%d\nn=%d\noy=%d\nleap=%d\nod=%d",m,n,oy,leap,od);
getch();

for(i=0;i<(mm-1);i++)
od=od+year[i];

printf("\nmonth od=%d",od);
getch();

if(flag==1)
od=od+dd;
else
od++;

if((leap(yy))&&(m>2))
{
printf("\n its a leap year");
od++;
}

od=od%7;
printf("\ndate odd day:%d",od);
getch();

if(flag==1)
{
printf("\n The day is:");
find_day(od);
getch();
}


int k=1;
if(flag==0)
{
while((od!=dy) && (k!=31))
{
k++;
od++;
od=od%7;
}
printf("\n odd day=%d:",k);
getch();

printf("\n The dates tat fall on tis days r:");
find_day(od);

while(k<32)
{
printf("\n%d",k);
k=k+7;
if(mm==2 && k>=28)
break;
}
getch();
}

printf("\n want to continue?:y/n");
if(getche()=='y')
main();

}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
fromme is offline Offline
2 posts
since Nov 2007
Nov 15th, 2007
0

Re: Calendar program

Do you honestly think that that unformatted code is going to be helpful over a month later?
And what is so difficult in understanding the post titled Read Me: Read This Before Posting? Is it not explicit enough?
Moderator
Reputation Points: 3281
Solved Threads: 896
Posting Sage
WaltP is offline Offline
7,749 posts
since May 2006
Nov 15th, 2007
0

Re: Calendar program

<laurel>That's another fine unformatted mess you've posted</hardy>
Not to mention
- using void main,
- using meaningless single letter identifiers,
- using obsolete headers
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C Forum Timeline: airplane seat reservation
Next Thread in C Forum Timeline: Need help processing and storing a whitespace-delimited c-string.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC