Question #264902

11. Make a program that will input hour, convert it into minutes and seconds. Display the minutes and seconds respectively. Your program will be terminated if you input zero in the hour.


Ex. Hour = 2


Minutes = 120


Seconds = 7200



Expert's answer

#include <iostream>
int main() {
	while (true) {
		int hour;
		std::cout << "Hour = ";
		std::cin >> hour;
		if (!hour) break;
		std::cout << "Minutes = " << hour * 60 << '\n';
		std::cout << "Seconds = " << hour * 60 * 60 << '\n';
	}
	return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS