C++ Programming - Functions - Discussion
Discussion Forum : Functions - Programs (Q.No. 7)
7.
Which of the following statement is correct about the program given below?
#include<iostream.h>
long GetNumber(long int Number)
{
return --Number;
}
float GetNumber(int Number)
{
return ++Number;
}
int main()
{
int x = 20;
int y = 30;
cout<< GetNumber(x) << " ";
cout<< GetNumber(y) ;
return 0;
}Discussion:
8 comments Page 1 of 1.
Ponkhi said:
5 years ago
I didn't get this part, please anyone can explain?
long GetNumber(long int Number)
{
return --Number;
}
long GetNumber(long int Number)
{
return --Number;
}
Priyanka said:
5 years ago
I think the answer will be 21 29.
Amit saxena said:
9 years ago
I think the answer will be 19, 29. Reason in case of overloading match to call is from top to bottom. In the above question long int is higher data type thus, can accept int for both the calls.
Suresh Gupta said:
1 decade ago
float GetNumber (int Number) takes an integer arguments and its return type is float.
But why it returns integer value?
But why it returns integer value?
(1)
Swati said:
1 decade ago
cout<<GetNumber (x) <<" "; explain this y we used ""?
Dixit said:
1 decade ago
According to the parameter passed this function got called,
float GetNumber(int Number)
{
return ++Number;
}
float GetNumber(int Number)
{
return ++Number;
}
Hardik said:
1 decade ago
Typecasting will not done in argument. So int will treated as int and long int as long int.
Balasaheb said:
1 decade ago
20, 30 are in int format not in long int hence 2nd method is call.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers