+ 1
HOW CAN I MAKE IT WHEN I INPUT 11.6 the output is 11 hours 60 minutes and 0 degrees
#include <iostream> using namespace std; int main () { int a, b, c; double x; cout << "Input time: "; cin >> x; a = x; b = ((x-a)*100); c = (a*30 + (b/2)) % 360; cout << a << " hours " << b << " minutes and " << c << " degrees."; return 0; }
1 Réponse
+ 2
What are you converting to?
if it is time, 11.6 is not 11h 60m 0s. 60m would carry over to +1h. minutes at most only goes to 59.
11.6 would only be 11h 35m 59s.
And why is there degrees?
Are you sure about the calculation for c?
Here is a quick decimal time converter.
https://sololearn.com/compiler-playground/cl3y0C53bPR1/?ref=app