for statement in c++

#include <iostream>

int main() {
    for (int i = 0; i < 5; ++i) {
        std::cout << "Iteration: " << i << std::endl;
    }
    return 0;
}

Explanation:

  1. #include <iostream>: Include the input/output stream header file to enable the use of the standard input/output functions.

  2. int main() {: Define the main function, the entry point of the program.

  3. for (int i = 0; i < 5; ++i) {: Start of a for loop. The loop initializes an integer variable i to 0, executes the loop body as long as i is less than 5, and increments i by 1 in each iteration.

  4. std::cout << "Iteration: " << i << std::endl;: Output the current value of i along with the text "Iteration:" to the standard output.

  5. }: End of the for loop.

  6. return 0;: Indicate successful execution of the program and terminate the main function.

  7. }: End of the main function.