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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!