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 |
Is it possible to pass an object of the same class in place of object reference to the copy constructor?
what are the iterator and generic algorithms.
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; }
What do you know about friend class and friend function?
What do the keywords volatile and mean mutable?
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
What are multiple inheritances (virtual inheritance)?
How to demonstrate the use of a variable?
What is the use of object in c++?
Which programming language should I learn first?
What is class invariant in c++?
How is modularity introduced in C++?