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


Please Help Members By Posting Answers For Below Questions

What does new do in c++?

717


What are the various arithmetic operators in c++?

667


What are stacks? Give an example where they are useful.

670


What function initalizes variables in a class: a) Destructor b) Constitutor c) Constructor

780


What is the best c++ compiler for windows 10?

664






What are advantages of using friend classes?

730


What is near, far and huge pointers? How many bytes are occupied by them?

765


What's the "software peter principleā€?

714


What are the 2 main types of data structures?

684


What do you mean by early binding?

690


Why cstdlib is used in c++?

676


What are c++ data types?

730


Explain the differences between private, public and protected and give examples.

651


Is vector a class in c++?

689


Mention the storage classes in c++.

739