#include <iostream>
using namespace std; 
void counter ()
{
    static int count =0;
    cout <<count++<<endl; 
}
int main() {
    int i; 
    for (i=0;i<5;i++)
    {
        counter();
    }
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: