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



Consider the following code fragment: int main(void) { int m = 4; mystery ( m ); ..

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

Consider the following code fragment: int main(void) { int m = 4; mystery ( m ); ..

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

Post New Answer

More C++ General Interview Questions

What is the full form of india?

0 Answers  


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;

4 Answers   Lehman Brothers,


What is a sequence in c++?

0 Answers  


Explain pass by value and pass by reference.

0 Answers  


What are the uses of pointers?

0 Answers  






What's the order in which the objects in an array are destructed?

0 Answers  


Write a program for Divide a number with 2 and Print the output ( NOTE: Check for divide by zero error).

0 Answers  


what is multi-threading in C++?

0 Answers  


Can you please explain the difference between using macro and inline functions?

0 Answers  


What is a c++ map?

0 Answers  


What is the use of vtable?

0 Answers  


Explain deep copy?

0 Answers  


Categories