C++ Programming - Functions - Discussion

Discussion Forum : Functions - Programs (Q.No. 2)
2.
What will be the output of the following program?
#include<iostream.h>
int BixFunction(int a, int b = 3, int c = 3)
{
    cout<< ++a * ++b * --c ; 
    return 0;
}
int main()
{
    BixFunction(5, 0, 0); 
    return 0;
}
8
6
-6
-8
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
3 comments Page 1 of 1.

Ishwarya said:   1 decade ago
Here in main function

BixFunction(5, 0, 0) which will pass to a, b, c.

In cout<<++a * ++b * --c;

Here ++a is 6, ++b is 1, which is ++a * ++b=6.

Next --c is -1, which is 6*(-1) = (-6).

Adithya.R said:   8 years ago
a = 5 therefore ++a = 6 .
b = 0 therefore ++b = 1.
c = 0 therefore --c = -1.

Therefore final answer is -6.
(2)

Prince Singh said:   8 years ago
Thank you @Ishwarya.

Post your comments here:

Your comments will be displayed after verification.