for Loop (C++)

A C++ for loop repeats a block of code a controlled number of times. Its header has three parts: an initializer, a condition to keep looping, and an update…