With Static


#include "stdafx.h"
#include <iostream>


using namespace std;

// Program with static variable

void display()
{
  static 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=2
Value of n=3