#include <iostream>
using namespace std;
void fun ();
int main ()
{
int n;
cout << n << endl;
//for(int i=1;i<=5;i++) //calling the function using loop gives same results
//fun ();
//as these lines (calling them in each line)
fun ();
fun ();
fun ();
cout << n << endl;
return 0;
}
void
fun ()
{
int n;
n++;
cout << "n=" << n << endl;
}
output:
0
n=32719
n=32720
n=32721
0
my question is why the value of n increments as it is local variable. and it is not incremented if i print anything else between function calls.