Create a program using enum data type that asking date today in numerical (mm dd yyyy) and the output is today's date which month is in words (Jan dd yyy) and tomorrow's date.
Output is maybe like this:
Enter date Today: 01 15 2008
Today's date: Jan 15 2008
Tomorrow's date: Jan 16 2008
What is the code of this program using C?
I'm sure some other people would
gladly help you,
if you were to post
how far you are in your code, already.
Give a code snippet, or something.
You just can't ask for a program to be written,
that's a bit too much to ask, for the most part.
But, good luck!~
Reply:Do your own work.
Doodad
Reply:enum Months
{January=1, February, March, April, May, June, July, August, September,
October, November, December};
--%26gt; the enum must be outside of the main function. Also, you should start with index 0, not 1, this will make things easier.
int day, year, moni;
int c;
char mon[10][10][10] = {"January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"};
--%26gt; you don't need a 3-dimensional array, 2 is enough. also, usually you have 12 months, not 10, but you don't need to specify the size at all if you immediately initialize the array:
const char *mon[]={"January", "February"...};
printf("Enter Date Today:(in numerical) dd mm yyyy\n\n");
scanf("%26amp;d %26amp;d %26amp;d", moni, day, year);
--%26gt; must be scanf("%d %d %d", %26amp;moni, %26amp;day, %26amp;year);
for (c=January; c%26lt;=December; c++)
{
printf("%s %d %d", mon[moni-1], day, year);
}
--%26gt; ok, but mon[moni] does no longer need to use moni-1, if you use 0 as the start index for January.
printf("Tomorrow's Date:\n");
printf("%c %d %d", mon, day+1, year);
--%26gt; not so good, try this:
printf("%s %d %d", mon[moni], day+1, year);
good luck,
Chris
Reply:01 15 2008 then Jan 16 008 I guess
Reply:Easy. But, I'm not telling you.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment