Question
Code in C Write a function call to ConvertTime() to store the number of years, months, and days within the integer variables numYears, numMonths, and
Code in C
Write a function call to ConvertTime() to store the number of years, months, and days within the integer variables numYears, numMonths, and numDays, respectively.
Ex: If the input is 2227, then the output is:
Years: 6
Months: 1
Days: 7
Code:
#include
void ConvertTime(int totalDays, int* numYears, int* numMonths, int* numDays) { *numYears = totalDays / 365; totalDays = totalDays % 365; *numMonths = totalDays / 30; totalDays = totalDays % 30; *numDays = totalDays; }
int main(void) { int totalDays; int numYears; int numMonths; int numDays;
scanf("%d", &totalDays); /* Your code goes here */ printf("Years: %d ", numYears); printf("Months: %d ", numMonths); printf("Days: %d ", numDays); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started