Consider the following code fragment:
int main(void) {
int m = 4;
mystery ( m );
mystery ( m );
printf("%d", m);
return 0;
}
What is the output on the monitor if mystery is defined as
follows ?
void mystery (int m) {
m = m+3;
}
Answers were Sorted based on User's Feedback
Answer / c++ coder
Output will be 4 only.
since the argument is not passed by reference so a local
copy of m is used in the function call which is local to
mystery() it will not have any impact on the variable m
which is used in main() function.
| Is This Answer Correct ? | 6 Yes | 1 No |
Answer / rahul darekar
since in c lang we have to define fun first before we use it
but in this program fun mystery() in not defined and still
it is called so it will give error.
| Is This Answer Correct ? | 3 Yes | 1 No |
What is the benefit of c++?
What parameter does the constructor to an ofstream object take?
write a program to add two numbers without using an arithmetic operator.
Explain linked list using c++ with an example?
Why isn't sizeof for a struct equal to the sum of sizeof of each member?
How does work in c++?
the maximum length of a character constant can be a) 2 b) 1 c) 8
What is copy constructor? Can we make copy constructor private in c++?
What is a constructor and how is it called?
what is a class? Explain with an example.
What is this weird colon-member (" : ") syntax in the constructor?
What is the use of register keyword with the variables?