C++ for loop

The C++ for loop is used to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop than while or do-while loops.The C++ for loop is same as C/C#. We can initialize variable, check condition and increment/decrement value.


for(initialization; condition; increment/decrement){

//code to be executed




using namespace std;

int main(){

for(int i; i<=10; i++)




return 0;