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

How we can differentiate between a pre and post increment operators during overloading?

0 Answers  


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

0 Answers  


What are the rules about using an underscore in a c++ identifier?

0 Answers  


How to give an alternate name to a namespace?

0 Answers  


Describe protected access specifiers?

0 Answers  






Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

0 Answers  


Tell me an example where stacks are useful?

0 Answers  


Differentiate between a copy constructor and an overloaded assignment operator.

0 Answers  


How to change constant values?

6 Answers   Huawei, Symphony,


Do you know the problem with overriding functions?

0 Answers  


What do you understand by pure virtual function? Write about its use?

0 Answers  


What are the steps in the development cycle?

0 Answers  


Categories