cycle
for loop
for(init; condition; increment)
{
conditional code;
}
foreach loop
int myArray[5] = {0,1,2,3,4};
for (const int i : myArray)
{
cout << i << endl;
}
while loop
while(condition)
{
statement(s);
}
do-while loop
do {
statement(s);
}while( condition );
Loop control statements
- break
- continue
- goto
goto label;
label: statement;
Branch
if and else statements
if(boolean_expression)
{
}
else
{
}
switch statement
switch(expression)
{
case constant-expression :
statement(s);
break;
case constant-expression :
statement(s);
break;
default :
statement(s);
}
Please indicate the source, permanently updated links in this article: https://blogs.littlegenius.xin/2019/08/05/【C- refresher] three-cycle branch /