C++ Program take Hours, Minutes, Seconds and convert it in 24 Hours & Standard format

ad+1

Program

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com

#include<iostream>
using namespace std;

int main()
{
   int hour=0 ,min=0, second=0;                        

   cout<<"Enter hours: ";
   cin>>hour;

   cout<<"Enter minutes: ";
   cin>>min;

   cout<<"Enter seconds: ";
   cin>>second;

   if(hour > 24)
   {
     cout<<"Invalid Entery";
   }

   else
   {
    cout<<"\n****24 Hours Format****" <<endl;
    cout<<"Hours : Mins : Seconds" <<endl;
    cout<<hour<<" : "<<min<<" : "<<second <<endl;
   }

 
  if(hour > 12)
 {
  hour=hour-12;
  cout<<"\n****12 Hours Format****" <<endl;
  cout<<"Hours : Mins : Seconds" <<endl;
  cout<<hour<<" : "<<min<<" : "<<second <<endl;
 }

  else
  {
   cout<<"****12 Hours Format****" <<endl;
   cout<<"Hours : Mins : Seconds" <<endl;
   cout<<hour<<" : "<<min<<" : "<<second <<endl;
  }

}

Output:

2 comments: Leave Your Comments