In C please Write a function call to ConvertTime() to store the number of months, weeks, and days within the integer var

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In C please Write a function call to ConvertTime() to store the number of months, weeks, and days within the integer var

Post by answerhappygod »

In C please
Write a function call to ConvertTime() to store the number ofmonths, weeks, and days within the integer variables numMonths,numWeeks, and numDays, respectively.
Ex: If the input is 222, then the output is:
Months: 7 Weeks: 1 Days: 5
#include <stdio.h>
void ConvertTime(int totalDays, int* numMonths, int* numWeeks,int* numDays) { *numMonths = totalDays / 30; totalDays = totalDays % 30; *numWeeks = totalDays / 7; totalDays = totalDays % 7; *numDays = totalDays;}
int main(void) { int totalDays; int numMonths; int numWeeks; int numDays;
scanf("%d", &totalDays); /* Your code goes here */ printf("Months: %d\n", numMonths); printf("Weeks: %d\n", numWeeks); printf("Days: %d\n", numDays); return 0;}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply