Implementing C++ source code (How to convert seconds to H:M:S format)

Greetings team,
How could I implement this C++ source code that I wrote some years back? The purpose of the program is to enter the amount of seconds and to have the time displayed as:
Hour: Minutes: Seconds. C++ source code
case '1':
cout<<"Enter time in seconds: \t";
cin>>time;
hour= time/3600;
time= time%3600;
min= time/60;
time= time%60;
sec= time;
cout<<"\n\nThe time is : "<<"\t\t" <<hour<<"::"<<min<<"::"<<sec ;
cout<< "\n";
break;
Please view what I have tried so far, and

I'm getting -Infinity on the bottom line. I'm unable to find a way to declare the "Time" variable the way I did using C++

Hello,

This thread may help you.

1 Like

Open this blocks image in a separate window to browse it.
The .aia is at
https://groups.google.com/g/mitappinventortest/c/QBw5qNHEsxc/m/EmdKoQLMDwAJ
from a countdown timer.
AI2 has no int data types, so you always have to clip fractions using math blocks like floor, ceil, round, dividend, etc.

1 Like

Please check this as well,

1 Like

Is this what you want to do?

yes this is exactly what I'm looking to do. Do you have the details of how I should declare "Hour, Min and sec", or will the engine identify them respectively?

like this:

HMS

You can pretty it up too

1 Like

I want to go with the first logic illustration, however, how do I manage to get the Join to have more than just 2 slots? Please refer to my picture in order to see how mine is looking.

Click on the 'gear' icon (blue) immediately preceding the word 'join'

I want to say thank you to everyone who had participated in this thread, this was a great experience with the wonderful community, my issue has been resolved. Keep up the good work. I'm looking forward to doing my part in the community.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.