Tuesday, 3 July 2018

how to convert sec into hour, min,sec in c++

Write a programm that take the time from user in second and
convert it into hour  mintue and second

////////// solutions 

   

#include <iostream>
using namespace std;

int main() {

 int sec;
    cout<<"Enter the time in seconds"<<endl;
cin>>sec;
int hour ,min;
hour=sec/3600;
sec%=3600;
min=sec/60;
sec%=60;


cout<<hour<<" : "<<min<<"  :  "<<sec<<endl;

No comments:

Post a Comment