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;
}
Answer Posted / 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 |
Post New Answer View All Answers
What does new do in c++?
What are the various arithmetic operators in c++?
What are stacks? Give an example where they are useful.
What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor
What is the best c++ compiler for windows 10?
What are advantages of using friend classes?
What is near, far and huge pointers? How many bytes are occupied by them?
What's the "software peter principleā?
What are the 2 main types of data structures?
What do you mean by early binding?
Why cstdlib is used in c++?
What are c++ data types?
Explain the differences between private, public and protected and give examples.
Is vector a class in c++?
Mention the storage classes in c++.