Write a function that, when you call it, displays a message how many times it has been called: "I have been called 3 times". write a main program that calls this function at least 10 times.

Recommended Answers

All 4 Replies

Get a global counter variable and increment it by one every time you call the function.

Actually, the simplest solution is to use a static local variable:

int call_counter()
{
    static int count = 0;

    return ++count;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.