C++ Program for Displaying Time in Seconds

Program Code:

#include<iostream>
using namespace std;
int main()
{
int h , m , s , t_sec ;
cout<<"Enter Time: \n";
cin>>h>>m>>s;

t_sec =  (h * 60 *60) + (  m * 60) + s ;

cout<<"\n\nTotal seconds are :  "<<t_sec;

return 0;
}

Output:

.exe file

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.