Give the output of the following program. What happens if you run this program many times?
#include <iostream>
using namespace std;
void f();
void g();
int main()
{
int i = 10;
cout << "In main:(1): " << i << endl;
f();
cout << "In main:(2): " << i << endl;
g();
cout << "In main:(3): " << i << endl;
return 0;
}
void f()
{
int i;
cout << "In f:(1): " << i << endl;
i = 20;
cout << "In f:(2): " << i << endl;
g();
cout << "In f:(3): " << i << endl;
}
void g()
{
int i;
cout << "In g:(1): " << i << endl;
i=30;
cout << "In g:(2): " << i << endl;
}