24-HR to AM/PM converter (call by reference code). Why wont my code work ??

So here is the code, I seriously don't understand why its not working...
#include<iostream>
using namespace std;
void inp(int&,int&);
void conv(int&,int&,char&);
void outp(int,int,char);
void main()
{
	int hours,minutes;
	char ampm;
	char loopdesire;
	do{
		void inp(hours,minutes);
		void conv(hours,minutes,ampm);
		void outp(hours,minutes,ampm);
		cout<<"Do you wish to conduct a another conversion (y/n)?";
		cin>>loopdesire;
	}while(loopdesire=='y' || loopdesire=='Y');
}
void inp(int& hours,int& minutes)
{
	do{
		cout<<"Please enter hour";
		cin>>hours;
		if(hours > 23)
			cout<<"Enter hour value between 0 and 23";
	}while (hours>23);
	do{
		cout<<"Please enter minute";
		cin>>minutes;
		if(minutes>59)
			cout<<"Enter minute value between 0 and 59";
	}while (minutes>59);
}
void conv(int& hours, int& minutes, char& ampm)
{
	if(hours>12)
	{
		hours=hours-12;
		ampm='P';
	}
	else if(hours==12)
	{
		ampm='P';
	}
	else
	{
		ampm='A';
		}
}
void outp(int hours, int minutes, char ampm)
{
	cout<<"The time is"<<hours<<":"<<minutes<<ampm<<"M"<<" in A.M P.M. notation";
}
Read this:
http://cplusplus.com/forum/articles/40071/#msg218019


Anyway, problems I immediatley saw were that you're calling your functions incorrectly. In main():

1
2
3
4
// BAD
		void inp(hours,minutes);
		void conv(hours,minutes,ampm);
		void outp(hours,minutes,ampm);


1
2
3
4
// GOOD
		inp(hours,minutes);
		conv(hours,minutes,ampm);
		outp(hours,minutes,ampm);


When calling functions, you do not put the return type.

Also, main() should return an int, not a void (int main())
Hahaha wow. Thank you :)...Final exams around the corner and I've been up for 20 hours right now...
Topic archived. No new replies allowed.