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 pulse code modulation?

2 Answers   Wipro,


Explain the static storage classes in c++.

0 Answers  


What is istream and ostream in c++?

0 Answers  


What are raw sockets, where they are efficient?

2 Answers   Symphony,


What is null and void pointer?

0 Answers  






What are the advantages of using a pointer?

0 Answers  


How does c++ structure differ from c++ class?

0 Answers  


Explain the need for "Virtual Destructor"?

2 Answers   Infosys,


What is private public protected in c++?

0 Answers  


What is the use of volatile keyword in c++? Give an example.

1 Answers  


What is "map" in STL?

2 Answers  


What do you mean by volatile and mutable keywords used in c++?

0 Answers  


Categories