Computer Science, asked by aradhyasharma17, 9 months ago


What is the default STEP value in a FOR...NEXT loop? Is it possible to have a negative value in STEP?​

Answers

Answered by sarwatzaman
34

Answer:

What is the default step value in for next loop?

step value is the value by which the counter variable is incremented or decremented every time the loop body is executed. It can be a positive or a negative value, but it cannot be zero. The step value is optional.

Answered by rudransh89
12

Answer:

follow me and mark as brainlist

Explanation:

For counter = start To end [ Step step ]

[ statements ]

[ Exit For ]

[ statements ]

Next [ counter ]The step argument can be either positive or negative. The value of the step argument determines loop processing as follows.

TABLE 2

Value Loop executes if

Positive or 0 counter <= end

Negative counter >= end

After all statements in the loop have executed, step is added to counter. At this point, either the statements in the loop execute again (based on the same test that caused the loop to execute initially), or the loop is exited and execution continues with the statement following the Next statement.

Tip

Changing the value of counter while inside a loop can make it more difficult to read and debug your code.

Any number of Exit For statements may be placed anywhere in the loop as an alternate way to exit. Exit For is often used after evaluating some condition, for example If...Then, and transfers control to the statement immediately following Next.

You can nest For...Next loops by placing one For...Next loop within another. Give each loop a unique variable name as its counter. The following construction is correct:

VB

Copy

For I = 1 To 10

For J = 1 To 10

For K = 1 To 10

...

Next K

Next J

Next I

Similar questions