i have a problem with a function
Apr 15, 2013 at 7:36am
i get an error in line 16, what am i doing wrong?
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
|
#include<iostream>
using namespace std;
int getnumber(int high = 5, int low = 1);
main(){
int number;
number = getnumber();
return 0;
}
int getnumber (high,low){
cout << "choose a number (" << low << "-" << high << ")";
int number;
cin >> number;
if(number > high) {
number = high;
}
if(number < low) {
number = low;
}
return number;
}
|
Apr 15, 2013 at 7:45am
The arguments in the function should be the same as in the function prototype. For example
1 2
|
int getnumber (int high = 5, int low =1)
//function code goes here.
|
Apr 15, 2013 at 8:09am
(On line 16:) You need to put the data type before each parameter.
1 2 3 4
|
//line 16
int getnumber(int high, int low) {
...
}
|
Apr 15, 2013 at 9:40am
ok thanks for the help
Topic archived. No new replies allowed.