C++ Programming - Functions - Discussion
Discussion Forum : Functions - General Questions (Q.No. 1)
1.
Which of the following function prototype is perfectly acceptable?
Discussion:
19 comments Page 1 of 2.
Deepak said:
1 decade ago
Parameters are can not be write inside in any parameters.
Pankaj Thapa said:
1 decade ago
If a is correct then how b is incorrect it is calling a method using parameters which perfectly satisfies the syntax used for calling a method.
Aman Goel said:
1 decade ago
Because if we talk about the function with argument then return type of function is very important.
Function return type tells that what type of value is function return.
Function return type tells that what type of value is function return.
NISHU said:
1 decade ago
You can't compare the value of one function to value of the variable TEMP ;if you want to then arguments should be used exactly not with their type. i.e., Direct variable on which this function is applied.
Sandy said:
1 decade ago
How you can say that show in A is also returning a compatiable or you can int type value. And why not in option B?
Hemanth said:
1 decade ago
Obviously the option A is correct answer the arguments where given in the option A so it is true where as in option B there are no arguments in prototype in the side of int and float. So it is false. :-).
Doga said:
1 decade ago
This is the case of the default argument, hence show should be like show (a, b) or show (2, 4.232), or such n such. But show (int, float) are data type that provide the default value to the function argument so give error. But show has no argument so possibly return some value if its definition has return.
Sushovan Das said:
1 decade ago
Option A is correct as in a parameter any other parameter can not be passed.
Bhanu said:
1 decade ago
Here While calling a function if another function is passed as parameter then that function should have values as parameter inside parenthesis not the data type.
int Function(int Tmp = Show());
or
int Function(int Tmp = Show(2,3.2));
Both are correct.
But
int Function(int Tmp = Show(int x , float y)); // Incorrect.
int Function(int Tmp = Show());
or
int Function(int Tmp = Show(2,3.2));
Both are correct.
But
int Function(int Tmp = Show(int x , float y)); // Incorrect.
(2)
Shahzada said:
1 decade ago
Yes option A is correct answer because in A function prototyping show function is called but in option B in prototyping of one function another prototyping is given which is not according to the syntax of function prototyping because return typing is not given.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers