Question
1.
#include
2.
using namespace std;
3.
void swap(int &a, int &b);
4.
int main()
5.
{
6.
int a = 5, b = 10;
7.
swap(a, b);
8.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
void swap(int &a, int &b);
4.
int main()
5.
{
6.
int a = 5, b = 10;
7.
swap(a, b);
8.
cout
Answer: Option A
Was this answer helpful ?
As we are calling by reference the values in the address also changed. So the main and swap
values also changed.
Output:
$ g++ ref.cpp
$ a.out
In swap 105 In main 105
Was this answer helpful ?
More Questions on This Topic :
Question 10.
Which of the following statement is correct?
....
Submit Solution