CppBuzz.com
  
Home C C++ Java Python Perl PHP SQL Javascript Linux Forum

You are here : Home » Solved Programs on C++ » C++ program to calulate seconds

C++ program to calulate seconds in given time

#include<iostream>
using namespace std;

unsigned long int calcualteSeconds(unsigned int hours, unsigned int minutes, unsigned int seconds)
{
unsigned long calSec = 0;

calSec = hours * 60 * 60;
calSec = calSec + minutes * 60;
calSec = calSec + seconds;
return calSec;
}

int main()
{
unsigned int hours, minutes, seconds;
unsigned long int CalculateSeconds  = 0;

cout<<"\n Enter hours : ";
cin>>hours;

cout<<"\n Enter minutes : ";
cin>>minutes;

cout<<"\n Enter seconds : ";
cin>>seconds;

CalculateSeconds = calcualteSeconds(hours, minutes, seconds);
cout<<"\n No of Seconds are : "<< CalculateSeconds;

return 0;
}