Question
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
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
Answer: Option B
Was this answer helpful ?
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 ?
Submit Solution