using namespace std;
// declaring global variable
cout<<"In main() the value of i is:" <<i;
cout<<"Back in main the value of i is"<<i;
cout<<"In f() the value of i is:"<<i;
Your program might compile but does the compiler produce any errors or warnings? You have to fix them befre you can run the program. I spot at least one error -- line 13, functions have to be declared before they can be called.