Well I did some changes..still not getting what i need. How do I figure out the first week in January? posting 2 changes. First:
Code:
#define _CRT_SECURE_NO_WARNINGS
#define numdays ((yyyy-1)*365+(yyyy-1/4)-(yyyy-1/100)+(yyyy-1/400))
#include <stdio.h>
void main()
{
int mm;
int dd;
int yyyy;
int numdays;
int day;
printf("Please enter date (m d y):");
scanf("%d %d %d", &mm, &dd, &yyyy);
printf("%d/%d/%d =>", mm, dd, yyyy);
if(!(yyyy%4) && (yyyy%100) || !(yyyy%400));
day+1;
switch(mm)
{
case 1: numdays +31; break;//Jan
case 2: numdays +31+28; break;//Feb
case 3: numdays +31+28+31; break;//Mar
case 4: numdays +31+28+31+30; break; //Apr
case 5: numdays +31+28+31+30+31; break; //May
case 6: numdays +31+28+31+30+31+30; break;//Jun
case 7: numdays +31+28+31+30+31+30+31; break;//Jul
case 8: numdays +31+28+31+30+31+30+31+30; break; //Aug
case 9: numdays +31+28+31+30+31+30+31+30+31; break;//Sep
case 10: numdays +31+28+31+30+31+30+31+30+31+30; break;//Oct
case 11: numdays +31+28+31+30+31+30+31+30+31+30+31; break; //Nov
case 12: numdays +31+28+31+30+31+30+31+30+31+30+31+31; break; //Dec
}
day=numdays+mm+yyyy;
switch(day%7)
{
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;
}
}
The one above came the closest to me figuring out the correct output, as its matching the sample runs given to me.
Next:
Code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void main()
{
int mm;
int dd;
int yyyy;
int numdays;
printf("Please enter date (m d y):");
scanf("%d %d %d", &mm, &dd, &yyyy);
printf("%d/%d/%d =>", mm, dd, yyyy);
numdays =((yyyy-1)*365+(yyyy-1/4)-(yyyy-1/100)+(yyyy-1/400));
switch(mm)
{
case 1: numdays +=0; break;//Jan
case 2: numdays +=31; break;//Feb
case 3: numdays +=31+28; break;//Mar
case 4: numdays +=31+28+31; break; //Apr
case 5: numdays +=31+28+31+30; break; //May
case 6: numdays +=31+28+31+30+31; break;//Jun
case 7: numdays +=31+28+31+30+31+30; break;//Jul
case 8: numdays +=31+28+31+30+31+30+31; break; //Aug
case 9: numdays +=31+28+31+30+31+30+31+30; break;//Sep
case 10: numdays +=31+28+31+30+31+30+31+30+31; break;//Oct
case 11: numdays +=31+28+31+30+31+30+31+30+31+30; break; //Nov
case 12: numdays +=31+28+31+30+31+30+31+30+31+30+31; break; //Dec
}
if(!(yyyy%4) && (yyyy%100) || !(yyyy%400));
numdays = numdays+1;
switch(numdays%7)
{
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;
}
}
This one isnt doing what it should, not even close. Still dont know how to figure out first week of january, because it changes on a given year. Ive read the book and chapter multiple times. I cant ask for help this weekend because school is closed till tues.