Which fields are optional in a for loop in c++
vaibhavsrivastava:
Do you want to make an infinite loop?
Answers
Answered by
3
In a for loop Initialization, Termination and Increment-Decrement expressions are optional. It is possible to run a for loop without these expressions.
A for loop can be made as follows:
for(Initialization; Termination; Increment-Decrement)
{
statement
}
This loop will initialize the variable and execute the statement while increasing/decreasing the variable up to its termination value.
without these parameters a for loop can also be constructed like
for ( ; ; )
{
statement
}
This loop will run indefinitely executing the statement.
so in a for loop Initialization, Termination and Increment-Decrement expressions are optional.
Similar questions