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

Is it possible to pass an object of the same class in place of object reference to the copy constructor?

0 Answers  


what are the iterator and generic algorithms.

0 Answers  


template<class T, class X> class Obj { T my_t; X my_x; public: Obj(T t, X x) : my_t(t), my_x(x) { } }; Referring to the sample code above, which one of the following is a valid conversion operator for the type T? a) T operator T () { return my_t; } b) T operator(T) const { return my_t; } c) operator(T) { return my_t; } d) T operator T (const Obj &obj) { return obj.my_t; } e) operator T () const { return my_t; }

1 Answers   Quark,


What do you know about friend class and friend function?

1 Answers  


What do the keywords volatile and mean mutable?

0 Answers  






Of the numbers 12 23 9 28 which would be at the top of a properly implemented maxheap a) 28 b) 9 c) Any of them could be

0 Answers  


What are multiple inheritances (virtual inheritance)?

0 Answers  


How to demonstrate the use of a variable?

0 Answers  


What is the use of object in c++?

0 Answers  


Which programming language should I learn first?

0 Answers  


What is class invariant in c++?

0 Answers  


How is modularity introduced in C++?

0 Answers   TCS,


Categories