I am sorry to repost a question about a calendar, because i've done some searching and found similar problems.

The program shoudl function like this:
1 - User enters the date of birth mm , then dd, then yy
2 - program gives the day of the week for that given date, with respect to leap years.

This is what i have so far. When I run the program and give the date, it just kicks some numbers back to me. I'm fairly new to programming. PLEASE HELP!

Thanks,

/* Write a program that, given a person's birthdate (or any other date in the
gregorian calendar) will display the day of the week that the person was born.
*/

#include <stdio.h>
/* Prototype Declarations */
void get_data(int *year, int *month, int *day);
int calc_day(int year, int month, int day);
void print_results(int total);

int main()
{
/* Local Definitons */
int year;
int month;
int day;
int total;

get_data(&year, &month, &day);
total = calc_day(year, month, day);
print_results(total);

return 0;
}

void get_data(int *year, int *month, int *day)
{

printf("\nEnter the Month of the Person's Birthdate:\n");
scanf("%d", &month);
printf("\nEnter the Day of the Person's Birthdate:\n");
scanf("%d", &day);
printf("\nEnter the Year of the Person's Birthdate:\n");
scanf("%d", &year);
printf("\nHere is the date entered: %d/%d/%d\n", month, day, year);
return;
}

int calc_day(int year, int month, int day)
{
/* Local Definitons */
int dayofdec31;
int total;
/* Calculate Day of December 31 */
dayofdec31 = ((((year - 1)*365) + ((year - 1)/100) + ((year - 1)/400)) % 7);

total = 0;
switch (month)
{
case 12 : total = total + 30;
case 11 : total = total + 31;
case 10 : total = total + 30;
case 9 : total = total + 31;
case 8 : total = total + 30;
case 7 : total = total + 31;
case 6 : total = total + 30;
case 5 : total = total + 31;
case 4 : total = total + 30;
case 3 : total = total + 31;
case 2 : total = total + 28;
case 1 : total = total + 0;

}
/* Calculate Leap year */
if ((!(year % 4) && (year % 100) ) || !(year % 400))
{
if (month > 2)
{
total = (total + day + 1);
}
}
else
{
total = (total + day);
}

return ((total + dayofdec31)%7);
}

void print_results(int total)
{
/* Local Definitons */
int days;

switch(days)
{
case 0 : printf("Sunday\n");
break;
case 1 : printf("Monday\n");
break;
case 2 : printf("Tuesday\n");
break;
case 3 : printf("Wednesday\n");
break;
case 4 : printf("Thursday\n");
break;
case 5 : printf("Friday\n");
break;
case 6 : printf("Saturday\n");
break;
}
printf("\nThe Person's Birthday Is On: %d\n", days);

getch();
return;

} 2. Using [code] [/code] tags makes posted code easier to read.
Code:
```void get_data(int *year, int *month, int *day)
{

printf("\nEnter the Month of the Person's Birthdate:\n");
scanf("%d", &month); /* month is a pointer, remove the '&' */
printf("\nEnter the Day of the Person's Birthdate:\n");
scanf("%d", &day);   /* day is a pointer, remove the '&' */
printf("\nEnter the Year of the Person's Birthdate:\n");
scanf("%d", &year);  /* year is a pointer, remove the '&' */
printf("\nHere is the date entered: %d/%d/%d\n",  *month, *day, *year);
return;
}```
Code:
```void print_results(int total)
{
/* Local Definitons */
int days;

switch ( days ) /* Symbol 'days' not initialized */
{
case 0 : printf("Sunday\n");
break;
case 1 : printf("Monday\n");
break;
case 2 : printf("Tuesday\n");
break;
case 3 : printf("Wednesday\n");
break;
case 4 : printf("Thursday\n");
break;
case 5 : printf("Friday\n");
break;
case 6 : printf("Saturday\n");
break;
}
printf("\nThe Person's Birthday Is On: %d\n", days);

getch();
return;

} /* Symbol 'total' not referenced */```
There are still problems with the calculations, I didn't look into that.
Code:
```Enter the Month of the Person's Birthdate:
4

Enter the Day of the Person's Birthdate:
22

Enter the Year of the Person's Birthdate:
2003

Here is the date entered: 4/22/2003
Wednesday

The Person's Birthday Is On: 3``` 3. How did you get those results? I made the same changes you made to the program, and I got pretty much the same results as before...

thanks for helping 4. Oops. I had used the following for the sample run.
Code:
```void print_results(int total)
{
/* Local Definitons */
int days = total;

switch ( days )```
It didn't make sense to have both the "not initialized" and "not referenced" comments in there along with my guess at your intent. 5. You're a lifesaver. Sometimes when you're new to this, if you stare at the screen too long, you can overlook things like that.
Thanks very much for your help.

I still have to figure out why it's calculating the days incorrectly, but that could be just a typo on my part.
Thanks again,
Ryan Popular pages Recent additions 