C++ program seconds to hours:minutes:seconds convert
21 replies, posted
I am new to C++ and i need some help with the programming part. I use visual studios 2005. This is what i have so far but i'm pretty much lost.
int main ()
{
int seconds;
int min;
int hour;
int total;
cout << "Enter the value in seconds: " << endl;
cin >> total;
hour = total / 3600;
hour = hour % 3600;
min = total / 60;
min = min % 60;
seconds = total / 60;
seconds = seconds % 60;
cout << hour << ":" << minute << ":" << seconds << endl;
return 0;
}
1. There's already Visual Studio 2010, so you better use that
2. What is the problem with the code?
idk what the problem is but it failed when i compiled it..
Maybe add the required include as well at the beginning of the file
[cpp]#include <iostream>
using namespace std;[/cpp]
i have that just didn't copy n paste it. sorry haha
Next time you should copy that also. Anyways I found that you declare & use variable "min", but cout variable named "minute".
For future reference, when you post code that doesn't work, please include the entirety of the code, as well as the error that accompanies it.
thanks guys!
[QUOTE=sim642;25549327]Next time you should copy that also. Anyways I found that you declare & use variable "min", but cout variable named "minute".[/QUOTE]
How in the fuu did you miss that?
i donnooooo
[QUOTE=sim642;25548617]1. There's already Visual Studio 2010, so you better use that
2. What is the problem with the code?[/QUOTE]
I use 2008. Try to stop me.
I use dev-C++
:huh:
[QUOTE=dj0wns;25557966]I use dev-C++
:huh:[/QUOTE]
What the fuck is wrong with you.
I use vi and gcc suck it.
Not really.
I used to use Dev-C++ until I found C# and with it Visual Studio 2010...Never going back.
[QUOTE=nikomo;25559127]I use vi and gcc suck it.
Not really.[/QUOTE]
I use vim and GCC and it's awesome.
Really.
[QUOTE=Corewarp3;25551368]How in the fuu did you miss that?[/QUOTE]
I didn't bother looking any further when I didn't see any includes.
[QUOTE=dj0wns;25557966]I use dev-C++
:huh:[/QUOTE]
Me too.
:huh:
Why the fuck You dont post compiling errors just go and shout "IT FAILS TO COMPILE HALP HALP HALP".
Help us help You next time.
[QUOTE=Amic;25573592]Why the fuck You dont post compiling errors just go and shout "IT FAILS TO COMPILE HALP HALP HALP".
Help us help You next time.[/QUOTE]
Then we shall thank you for helping us help you help us all.
[QUOTE=esalaka;25574030]Then we shall thank you for helping us help you help us all.[/QUOTE]
Shush. Its just me being useful dick.
Sorry, you need to Log In to post a reply to this thread.