What will be the output of the program and what is the reason for this

#include
using namespace std;
int f(int i, int &r, int *p)
{
r = 2 * i;
i= *p + 10;
*p += 2;
cout << "i: " << i << endl;
return r;
}
int main()
{
int val= 12;
res = f(val, val, &val);
cout << "res: " << res << ", val: " << val << endl;
return 0;
}
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories