What output will be produced by the following include using
What output will be produced by the following #include using namespace std; const int n = 10; void fund (int, int&. int&); int main 0 {int a =45. b = 35, c = 20; fund1 (a. b, c); cout
Solution
#include <iostream>
using namespace std;
const int n=10;
void func1(int,int&,int&);
int main()
{
int a =45,
b = 35,
c = 20;
func1(a,b,c);
cout<<a<<\" \"<<b<<\" \"<<c<<endl; //back in main a = 45 does not change, passed by value but b and c changed as passed by reference
return 0;
}
void func1(int w,int& y,int &z)
{
cout<<w<<\" \"<<y<<\" \"<<z<<endl; // 45 35 20 as passed by main()
w=18;
y=20;
z=w+1;
cout<<w<<\" \"<<y<<\" \"<<z<<endl; // new values 18 20 19(18+1)
}
