"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Monday, April 26, 2010

WAP to input time in seconds and convert it into hh-mm-ss format


#include<iostream.h>
#include<conio.h>

void main()
{
int sec, s, m, h;

cout<< "\n Enter time in seconds :";
cin >> sec;
h = sec/3600; //hours
sec = sec%3600; // remaining seconds
m = sec/60; // minutes
s = sec%60; // remaining seconds

cout << "\n HH-MM-SS  : " << h << ":" << m << ":" << s;
getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.