Error on time conversion program

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';
}

else if (hours == 12)
{ am_pm ='P';
}
else
{am_pm = 'A';
}
}

int show_output (int hours, int minutes, char am_pm)
{
cout<<"Time converted is " <<hours<<":"<<minutes<<am_pm<<"M"<<endl;

}


don't include the type when you call the function, you also need get_input to be by reference:
1
2
3
4
5
6
7
8
9
10
11
12
int get_input(int& , int& );

int main(){
 int x, y;
 get_input(x,y);
 return 0;
}

int get_input(int& x, int& y){
  //Do stuff
  return 0;
}


There might be others that need to be by reference to.
Thanks, I knew it was something simple. and yes the second function had to be by reference as well.
you rock man. Thanks for your time
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cstdlib>
#include <time.h>

using namespace std;

int wait ( int seconds ){
    clock_t endwait;
    endwait = clock() + seconds * CLOCKS_PER_SEC ;
    while (clock() < endwait) {}
    return 0;
}

int main(){
    int hours = 0, minutes = 0, seconds = 0;
    
    while (hours>=0){
        if( minutes < 10){
            cout << hours << ":0" << minutes << ":" << seconds << '\n';
        }
        else{
            cout << hours << ":" << minutes << ":" << seconds << '\n';
        }
        wait(1);
    ++seconds; 
    if(seconds == 60){ 
        seconds-= 60;   
        ++minutes;
    }
    if(minutes == 60){
        minutes-=60;  
        ++hours;
    }      
}
    return 0;
}
the conversion you should is the same as mine in the functions. and removing the system pause is a great idea.
Topic archived. No new replies allowed.