-
What is the output of this program?
#include
using namespace std;
void swap(int &p, int &q);
int main()
{
int p = 5, q = 10;
swap(p, q);
cout << " In main " << p << q;
return 0;
}
void swap(int &p, int &q)
{
int temp;
temp = p;
p = q;
q = temp;
cout << "In swap " << p << q;
}
-
- In swap 11 15
- In main 11 15
- Compilation Error
- Runtime Error
- In swap 11 15 In main 11 15
Correct Option: E
As we are calling by reference the values in the address also changed. So the main and swap values also changed.