counter for call function

#include <iostream>
using namespace std;

int f()

{static int i;

return ++i;

}

int main ()

{

int i,counter = 0;

for (i=0;i<10;i++)

counter = f();

printf(“%d\n”,counter);

system(“pause”);

return 0;

}

Or

#include <iostream>

using namespace std;

int counter;

int f()

{

++counter;

}

int main ()

{

int i;

for (i=0;i<10;i++)

f();

printf(“%d\n”,counter);

system(“pause”);

return 0;

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: