C++ Programming - Functions - Discussion

Discussion Forum : Functions - Programs (Q.No. 14)
14.
Which of the following statement is correct about the program given below?
#include<iostream.h>
const double BixConstant(const int, const int = 0);
int main()
{
    const int c = 2 ;
    cout<< BixConstant(c, 10)<< " "; 
    cout<< BixConstant(c, 20)<< endl; 
    return 0;
}
const double BixConstant(const int x, const int y)
{
    return( (y + (y * x) * x % y) * 0.2);
}
The program will print the output 2 4.
The program will print the output 20 40.
The program will print the output 10 20.
The program will print the output 20 4.50.
The program will report compile time error.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Omkar said:   8 years ago
Error because function definition of one function is not present as cpp is strict type checking. So compile time error.

Gurnam singh saini mukerian wale said:   1 decade ago
Can arguments override constant parameters?

If yes why we call them constants?

Ashwak said:   1 decade ago
Here, in the first call x=2 and y=10.

So it returns, (10+(10*2)*2%10)*0.2;
=(10+20*2%10)*0.2;
=(10+40%10)*0.2;
=(10+0)*0.2;
=10*0.2;
=2.

In the second call, x=2 and y=20.

So it returns, (20+(20*2)*2%20)*0.2;
=(20+40*2%20)*0.2;
=(20+80%20)*0.2;
=(20+0)*0.2;
=20*0.2;
=4.
(7)

Post your comments here:

Your comments will be displayed after verification.