Quote:
Originally Posted by MattNolan
You should use a void function to input meaning it does not return a value, you also need to pass two integers to it so your prototype should look like
void print (int,int);
And your function header should look like:
void print(int hrs, int mins)
Read up on passing variables to functions as well as invoking void functions and you should be able to figure out the function call and what should go within.
|
Thanks for the reply Matt,
I took what you said and applied it in my code here:
Code:
#include <iostream>
using namespace std;
void print(int,int); //prototype
int main()
{
cout << "Enter the number of hours: ";
int hrs;
cin >> hrs;
cout << "Enter the number of minutes: ";
int mins;
cin >> mins;
print(hrs,mins);
system("pause");
return 0;
}
void print(int hrsOut, int minsOut)
{
cout << "Time is: " << hrsOut << ":" << minsOut << endl;
}
It works nicely.
I'm not sure if this is considered wrong in any way (that meant, that I could've done it in a better way).
Thanks.