+ 1
I can't understand the loop for. Can you help me?
3 Respostas
+ 4
For loops uses a variable which you have to define the initial state, the ending condition, and what change you want to apply to this variable each time you repeat the loop (each separated by " ; ". It does :
for (initial state ; ending condition ; change)
Then, between { }, you write the actions you want to do each time you repeat the loop.
eg :
int X=0;
for (int i = 0; i < 10; i++){
cout>>>X
X++
}
//prints 0123456789
+ 3
hi,
for loop
syntax for(;;)
which is nothing but infinite loop
it requires two semicolon inside the for loop bracket.
for(initialization;condition;increment/decrement)
here all the values may be empty but it should require two semicolon.
we can initialize the loop var outside the loop or with in loop itself we can initialize.
condition can be applied
inc/dec can be done depends upon the program
pls refer this link
https://www.tutorialspoint.com/cprogramming/c_for_loop.htm
+ 1
Thank you