Ace Your C++ Skills 2026 – Rock the ‘Thinking in C++’ Challenge!

Get more with Examzify Plus

Remove ads, unlock favorites, save progress, and access premium tools across devices.

FavoritesSave progressAd-free
From $9.99Learn more

1 / 565

What is the output if func() is called 10 times and it increments a static integer initialized at 0?

It will print numbers 0 to 9.

It will print the number 10 ten times.

It will print numbers 1 to 10.

If the static integer is initialized at 0, each time the function is called it will increment the value by 1. Therefore, the first call will print 1, the second call will print 2, and so on until the tenth call which will print 10. This is because the static integer will retain its value between function calls. Option A is incorrect because it will print numbers 1 to 10, not 0 to 9. Option B is incorrect because it will only print the number 10, not numbers 1 to 10. Option D is incorrect because it will only print the number 1, not numbers 1 to 10.

Get further explanation with Examzify DeepDiveBeta

It will only print the number 1 ten times.

Next Question
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy