Loop Statements
1.1 The for Statement
void main()
{
// A maximum for the number of iterations
int max = 10;
// For statement
for(int i=0; i<max; i++)
{
// ...
}
// Or
int j;
for(j=0; j<max; j++)
{
// ...
}
}
1.2 The while Statement
void main()
{
while(condition)
{
// ...
// Update condition otherwise loops forever
}
}
1.3 The do..while Statement
void main()
{
do
{
// ...
// Update condition otherwise loops forever
}
while(condition);
}
Last modified: Wednesday, 13 November 2024, 8:26 AM