Can you solve this programming question in C or C Wikipedia

Can you solve this programming question in C or C++?

Wikipedia article name : Determination of the day of the week

Determination of the day of week for a given date is useful. It can be used to find out the day of week of someone\'s birthday in a given year, the day he/she was born or the day of a specific event. There are several algorithms for this purpose. You are going to implement two of the algorithms present in the Wikipedia article 1. The algorithm explained in the \"Disparate variation\" section 2. The algorithm explained in the \"Kraitchik\'s variation\" section mplement the Gregorian calendar versions of the algorithms. Do not use years smaller than 1582 since this is the year it was introduced. (However, it is possible to use years smaller than 1582, you can calculate the Julian calendar versions if you like). Implement these three algorithms and write an additional Main Class to test method that will print the week day of a given date using the three different algorithms. (Of course the result of all algorithms should be the same.)

Solution

# include <stdio.h>
# include <conio.h>
void main()
{
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char week[7][10] ;
int date, mon, year, i, r, s = 0 ;
clrscr();
strcpy(week[0], \"Sunday\") ;
strcpy(week[1], \"Monday\") ;
strcpy(week[2], \"Tuesday\") ;
strcpy(week[3], \"Wednesday\") ;
strcpy(week[4], \"Thursday\") ;
strcpy(week[5], \"Friday\") ;
strcpy(week[6], \"Saturday\") ;
printf(\"Enter a valid date (dd/mm/yyyy) : \") ;
scanf(\"%d / %d / %d\", &date, &mon, &year) ;
if( (year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)) )
month[1] = 29 ;
for(i = 0 ; i < mon - 1 ; i++)
s = s + month[i] ;
s = s + (date + year + (year / 4) - 2) ;
s = s % 7 ;
printf(\"\ The day is : %s\", week[s]) ;
getch() ;
}

Can you solve this programming question in C or C++? Wikipedia article name : Determination of the day of the week Determination of the day of week for a given

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site