Sunday, 15 June 2014

C++ program to convert time in seconds to hours, minutes and seconds



Here is a C++ program to convert time in seconds to hours, minutes and seconds


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
int main()
{
    int hour,minute,sec,sec1;
    cout<<"Enter seconds ";
    cin>>sec;
    sec1=sec;
    minute=sec/60;
    sec=sec-minute*60;
    hour=minute/60;
    minute=minute-hour*60;
    cout<<sec1<<" seconds = "<<hour<<" hour "<<minute<<" minute "<<sec<<" second";
}


Any questions regarding to program please write in comments.

No comments:

Post a Comment