Sail E0 Webinar
Question


What is the new value of x?


1.
#include
2.
using namespace std;
3.
void fun(int &x)
4.
{
5.
x = 20;
6.
}
7.
int main()
8.
{
9.
int x = 10;
10.
fun(x);
11.
cout
Options:
A .  10
B .  20
C .  15
D .  none of the mentioned
Answer: Option B

As we passed by reference, the value is changed and it is returned as 20.
Output:
$ g++ arg5.cpp
$ a.out
20



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers