Convert time-24-hour conversion to 12-hour conversion, allows repeated calculation:
// Convert time # include <iostream> using namespace STD; void get_time (Int & hours, Int & minutes); void convert_time (Int & hours, char & ampm ); void show_time (INT hours, int minutes, char ampm); int main () {int hours, minutes; char ans, ampm; do {get_time (hours, minutes ); convert_time (hours, ampm); show_time (hours, minutes, ampm); cout <"do you want again? "; CIN> ans;} while ('y' = ans | 'y' = ans);} void get_time (Int & hours, Int & minutes) {char B; cout <"Enter the time like 11: 11 format: \ n"; CIN> hours> B> minutes;} void convert_time (Int & hours, char & A) {If (hours <12) A = 'a'; else if (hours> 12) {hours-= 12; A = 'P ';} else if (hours = 12) {A = 'P' ;}} void show_time (INT hours, int minutes, char ampm) {cout <"the convert time is" Result:
Enter the time like 11: 11 format: 11: 30the convert time is 11: 30 Amdo you want again? Yenter the time like format: 15: 30the convert time is pmdo you want again? Yenter the time like format: 12: 30the convert time is pmdo you want again? Yenter the time like 11: 11 format: 0: 40The convert time is 0: 40 Amdo you want again?
Convert time-24 hour to 12 hour