Computer Science, asked by rajdeepsinghb, 11 months ago

Which fields are optional in a for loop in c++


vaibhavsrivastava: Do you want to make an infinite loop?

Answers

Answered by shubhamjoshi033
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