top of page
for loop spin statement 

A for is a self-repeating statement similar to a while statementThe variable is defined inside it, but the for statement contains three important elements:
We can write it in the compiler this way: {program commands}for(int i=o; i<5; i++)
1- Starting point (the definition)  int i=o 
2-End point (the conditioni<5
3-Change the counter value (the counter)  ++i
4-We open the curly braces and put the programming commands in them
Note: Variables must be separated
With semicolons

#include<iostream>//We start by placing the libraries
using namespace std;//We start by placing the libraries
int main(){//main function

for(int i=0;i<5;i++){
cout<<"hello"<<endl<<i<<endl;}
return 0;
}

image.png
bottom of page