Please use integer division and the modulus operator
Write a c++ program that take impute time in seconds. The program then output time in hours:minutes:seconds.?
void printHours(int time) {
printf("%d:",getHours(time);
}
int getHours(int time) {
if(time %26gt; 3600) {
return 1 + (getHours(time - 3600));
} else {
return 0;
}
}
void printMins(int time) {
time = time - (getHours(time) * 3600);
time = time - (time % 60);
printf("%d:", time/60);
}
int main(int argc, char** argv) {
int input;
scanf("%d", %26amp;input);
printHours(input);
printMins(input);
print("%d\n",input %60);
exit(0);
}
columbine
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment