Write a program in C++ to input hours , minutes and seconds. Calculate and print the total time in seconds.
Help me fast and I will follow u
Anonymous:
I m In class now , in 2 hrs I will help u , sorry
Answers
Answered by
0
#include <stdio.h>
int tot_mins; /* given number of minutes */
int hrs; /* number of hours (to be computed) */
int mins; /* number of minutes (to be computed) */
const int MINaHOUR = 60; /* number of minutes in an hour */
char line_text[50]; /* line of input from keyboard */
int main() {
printf("Input minutes: ");
fgets(line_text, sizeof(line_text), stdin);
sscanf(line_text, "%d", &tot_mins);
hrs = (tot_mins / MINaHOUR);
mins = (tot_mins % MINaHOUR);
printf("%d Hours, %d Minutes.\n", hrs, mins);
return(0);
}
HOPE THIS ANSWER WILL HELP YOU
Attachments:
Similar questions