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.
24 Hours format : 23:30:12
Standard format : 11:30:12 pm
C++ CODE using Turbo C++ IDE.
- #include<iostream.h>
- #include<conio.h>
- void main()
- {
- clrscr();
- int hours,mins,seconds,x;
- cout<<"Enter hours=";
- cin>>hours;
- cout<<"\nEnter minutes=";
- cin>>mins;
- cout<<"\nEnter seconds=";
- cin>>seconds;
- if(hours > 24)
- {
- cout<<"Invalid Entery";
- }
- else
- {
- cout<<"\n24 Hours Format\n";
- cout<<"Hours : Mins : Seconds\n"<<" "<<hours<<" : "<<mins<<" : "<<seconds<<"\n";
- if(hours > 12)
- {
- hours=hours-12;
- cout<<"12 Hours Format\n";
- cout<<"Hours : Mins : Seconds\n"<<" "<<hours<<" : "<<mins<<" : "<<seconds;
- }
- else
- {
- cout<<"12 Hours Format\n";
- cout<<"Hours : Mins : Seconds\n"<<" "<<hours<<": "<<mins<<" : "<<seconds;
- }
- }
- } // end of main
0 Response to "Program take hours, minutes, seconds and print it in 24 hours & standard format"
Post a Comment