Hello I need some help distinguishing whats wrong with this function?

+2 Bob huginstien · April 12, 2015
What is wrong with the following functions?

int f1(int n)
  cout << n;

f2(int n, m)
  n += m;

Post a Reply


Oldest  Newest  Rating
+2 K D · April 12, 2015
1. You must declare the parameters data type for every parameter
f2(int n, m) should look like f2(int n, int m).

2. you must also declare return type
void f2(int n, int m){
    f1(3.4);   // This will not work at expected 3.4 is of the wrong data type for f1

3. wrong return type on f1 or must return something.
0 Bob huginstien · April 12, 2015
Thank you very much!  I thought f1(3.4); looked very peculiar.  
+1 K D · April 12, 2015
Glad to help.
+1 Eyeshield Rosalin · April 12, 2015
Am I seeing 3.4 in this? f1(3.4); or maybe I'm wrong?
but declared as integer.

maybe you changed to float or double f1(3.4)

and f2 float or double (int m) // with one parameter only
but if KD's comments work then my mistake, just whoa! :)
0 Bob huginstien · April 12, 2015
No thank you for your input, it was in my professors power point slide and I was curious about. That is the exact format. :)
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator