in c Write a function call to ConvertTime() to store the number of hours, minutes, and seconds within the integer variab

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 Write a function call to ConvertTime() to store the number of hours, minutes, and seconds within the integer variab

Post by answerhappygod »

in c
Write a function call to ConvertTime() to store the number ofhours, minutes, and seconds within the integer variables numHours,numMinutes, and numSeconds, respectively.
Ex: If the input is 18108, then the output is:
Hours: 5 Minutes: 1 Seconds: 48
#include <stdio.h>
void ConvertTime(int totalSeconds, int* numHours, int*numMinutes, int* numSeconds) { *numHours = totalSeconds / 3600; totalSeconds = totalSeconds % 3600; *numMinutes = totalSeconds / 60; totalSeconds = totalSeconds % 60; *numSeconds = totalSeconds;}
int main(void) { int totalSeconds; int numHours; int numMinutes; int numSeconds;
scanf("%d", &totalSeconds); /* Your code goes here */ printf("Hours: %d\n", numHours); printf("Minutes: %d\n", numMinutes); printf("Seconds: %d\n", numSeconds); 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