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 full form of india?
What is the output of: String a1 = "Hello"; String a2 = "world!"; String* s1 = &a2; String& s2 = a1; s1 = &a1; s2 = a2; std::cout << *s1 << " " << s2 << std::endl;
What is a sequence in c++?
Explain pass by value and pass by reference.
What are the uses of pointers?
What's the order in which the objects in an array are destructed?
Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).
what is multi-threading in C++?
Can you please explain the difference between using macro and inline functions?
What is a c++ map?
What is the use of vtable?
Explain deep copy?