C++ Programming - Functions - Discussion

Discussion :: Functions - General Questions (Q.No.1)

1. 

Which of the following function prototype is perfectly acceptable?

[A]. int Function(int Tmp = Show());
[B]. float Function(int Tmp = Show(int, float));
[C]. Both A and B.
[D]. float = Show(int, float) Function(Tmp);

Answer: Option A

Explanation:

No answer description available for this question.

Deepak said: (May 14, 2012)  
Parameters are can not be write inside in any parameters.

Pankaj Thapa said: (May 14, 2012)  
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: (Jul 2, 2012)  
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.

Nishu said: (Jul 15, 2012)  
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: (Aug 15, 2012)  
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: (Oct 8, 2012)  
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: (Oct 12, 2012)  
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: (Feb 15, 2013)  
Option A is correct as in a parameter any other parameter can not be passed.

Bhanu said: (Apr 15, 2013)  
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.

Shahzada said: (Apr 15, 2013)  
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.

Prasadkumar said: (Aug 9, 2013)  
--------------------------------------------------------------------
[B]. float Function(int Tmp = Show(int, float));

In above option there is type but no arguments in show().

Actually the function definition is like this:

returntype funname(type arg1,type arg2) {
body
}
-----------------------------------------------------------

[D]. float = Show(int, float) Function(Tmp);

in the above function also same error id there.

Sree said: (Aug 11, 2013)  
In the case of function prototype I think the type of the arguments are to be specified not the variable name, here return type should be specified.

Karuppusamy said: (Sep 19, 2013)  
The statement in A only matches with the syntax of a function declaration.

Seema said: (Sep 26, 2013)  
B is incorrect as how do we send the arguments of function show.

Sunchuramya said: (Feb 9, 2015)  
First we should know the logic's to execute a program.

Vada said: (May 28, 2015)  
First know the logic's to execute.

Durgesh said: (Sep 16, 2015)  
float = Show(int, float) Function(Tmp);

Kmp said: (Sep 26, 2016)  
Parameters should not be initialized in the function argument.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.