Program take hours, minutes, seconds and print it in 24 hours & standard format

Program take hours, minutes, seconds and print it in 24 hours & standard format
Di Posting Oleh : Simple Learning
Kategori : Hours conversion program in C++ Hours Format Standards format and 24 format

 C++ program to display hours minutes and seconds in both  12 and 24 hours format:
24 Hours format : 23:30:12
Standard format : 11:30:12 pm
C++ CODE using Turbo C++ IDE.



  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {

  5.    clrscr();

  6.    int hours,mins,seconds,x;                         

  7.    cout<<"Enter hours=";

  8.    cin>>hours;

  9.    cout<<"\nEnter minutes=";

  10.    cin>>mins;

  11.    cout<<"\nEnter seconds=";

  12.    cin>>seconds;

  13.    if(hours > 24)

  14.     {

  15.      cout<<"Invalid Entery";

  16.    }

  17.    else

  18.    {

  19.        cout<<"\n24 Hours Format\n";

  20. cout<<"Hours  :  Mins  :  Seconds\n"<<"  "<<hours<<"  :     "<<mins<<"   :     "<<seconds<<"\n";

  21.   
  22.   if(hours > 12)

  23. {

  24.   hours=hours-12;

  25.   cout<<"12 Hours Format\n";

  26. cout<<"Hours  :  Mins  :  Seconds\n"<<"  "<<hours<<"  :     "<<mins<<"   :     "<<seconds;

  27.   }

  28.        else

  29.   {

  30.  cout<<"12 Hours Format\n";

  31.  cout<<"Hours  :  Mins  :  Seconds\n"<<" "<<hours<<": "<<mins<<"   :        "<<seconds;

  32.   }

  33.    }

  34. }                            // end of main


0 Response to "Program take hours, minutes, seconds and print it in 24 hours & standard format"

Post a Comment