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;
}
Discussion:
3 comments Page 1 of 1.
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.
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.
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).
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).
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers