Develop a computer program in C to answer the questions. Write a function that t
ID: 3720404 • Letter: D
Question
Develop a computer program in C to answer the questions.
Write a function that takes in: 1) an array MONTH I 1 (and an integer indicating the size of the array) that stores the days of each month in a particular year, 2) an integer first (=l to 7) that stores the day of week for January 1 of that particular year. 3) an integer pmont h pointer pointing to a month valuc. 4) an integer pday pointer pointing to a day valuc and output the day of the week for the month and day of that particular year For example, the month array for year 2017 is: MONTH1 121-131,28, 31, 30, 31, 30, 31,31, 30, 31,30, 311a January 1.2017 is a Sunday, so the integer first is 7(1 for Monday. 7 for Sunday, ctc) The output of the function should be 1 (Monday) for May 15.2017 (12.) What is the function header? (13.) What is the statement to call the function with the above mentioned case? (14) Write the function to detcrmine the day of the weck Hint: determine first how many days of the monith/day is to January I. and then use module operator IS) Write the main program to test the above function using the test case mentioned above. Depending on the result from the function, print out the day of the weck in the following format: The day of week for May 15 is Monday-Explanation / Answer
#include<stdio.h>
//Answer to Question 12
char* showDay(int month[12],int first,int *pMonth, int *pDay){
//Function body: Answer to Question 14
/*char* [] month_Name[12]={"January","February","March","April","May","June","July","August","September","October","November","December"};*/
char* [] days_Name[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int day,i;
//int month_Count=0;
int days_Count=0;
/*while(*month_Name[month_Count]!=*pMonth)
month_Count++;
*/
for( i=0;i<*pMonth;i++)
days_Count+=month[i];
days_Count+=*pDay;
day= days_Count%7;
return *days_Name[day];
}
int main(){
int month[]={31,28,31,30,31,30,31,31,30,31,30,31}
int first=7;
int *pmonth=5;
int *pday=15;
char * day=showDay(month[],first,*pmonth,*pday);
printf("The day of week for May 15 is %s.",*day);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.