Good afternoon,
I wrote a program that convers 24 hour input from user to a 12 hour time with AM and PM.
I did it without functions and it worked perfectly. The only problem is that when I implement 3 different functions (1 for input, 2 for conversion and 3 for output)but it seems like the main() just skips through the functions and does not read any of them. Anyways, here is my source code. I appreciate any help.
#include <iostream>
using namespace std;
int get_input(int,int);//Receives input from user.
int convert_time(int,int,char);//Converts military time to regular time.
int show_output(int,int,char);// Shows output to user.
int main()
{
int hours,minutes;
char am_pm;
int get_input(int hours, int minutes);
int convert_time (int hours, int& minutes, char am_pm);
int show_output (int hours_12, int minutes_12, char am_pm);
system("pause");
return 0;
}
int get_input(int hours_input, int minutes_input)
{
cout<<"This program will convert 24-hour notation to 12-hour notation\n";
cout<<"Enter hours in 24 hour notation \n";
cin>>hours_input;
cout<<"Enter minutes in 24 hour notation \n";
cin>>minutes_input;
return 0;
}
int convert_time (int hours, int minutes, char am_pm)
{
if (hours>12)
{
hours = hours-12;
am_pm = 'P';
}