What is the output of the following program?

What will be the output of the program and what is the reason for this output?
Write your answers in an ASCII-File

#include <iostream>
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;
No one here is going to do your h/w for you. Get a compiler and run it yourself. If you have any problems write them. Also, try to learn to use code tags.
There would be no output because it would not compile because 'res' has not been declared.
considering int res instead of res, the ouput will be 34.
thanks a lot buffbill n saurabh...
why only 34? i think output should be:

i: 34
res: 26, val: 26

Please correct me if I am wrong. Ofcourse I am assuming that the program compiles correctly.
Topic archived. No new replies allowed.