I am supposed to rite a program that convert the time from 24-hour notation to 12-hour notation and vice versa. My program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, my program must contain at least the following function:
i. function(s) to get the input, (hint: use pass-by-reference)
ii. a function to convert the time from 24-hour notation to 12-hour notation,
iii.a function to convert the time from 12-hour notation to 24-hour notation,
iv. function(s) to display the results.
but it is not building here is the code
#include <iostream>
int hour, minute, second, hours;
char type;
using namespace std;
int main()
{
int choice;
cout<< "Enter --"<< endl;
cout<< "1: To convert time from 12-hours notation."<< endl;
cout<< "2: To convert time from 24-hours notation."<< endl;
cout<< "99: To quite the program."<< endl;
cin>> choice;
if (choice == 2)
{
input1(hours, minute, second);
convert12to24( hour, type);
cout<< "The time is \t"<< hour << ":"<< minute<< ":"<< second<< " "<< type<< "M"<< endl;
}
else if (choice == 1)
{
input2(hours, minute, second);
convert24to12(hour, type);
cout<< "The time is \t"<< hour << ":"<< minute<< ":"<< second<< " "<< type<< "M"<< endl;
}
ok thank you i fixed it but i have a small problem now i want to write the a zero before minutes and seconds if there are less than 10 i tried setfill ('0') but it didnt work