Without Static
#include "stdafx.h"
#include <iostream>
using namespace std;
// Program without static variable
void display()
{
int n=0;
n++;
cout << "Value of n=" <<n << endl;
}
int main ()
{
static int count=0;
display();
display();
display();
return 0;
}
Output:
Value of n=1
Value of n=1
Value of n=1