FOR लूप कैसे प्रारंभ होता है?
How does a FOR loop start?
A
for i = 1 to 5
B
for (i <= 5; i++)
C
for (i = 0; i <= 5)
D
for (i = 0; i <= 5; i++)
Explanation
In most programming languages like JavaScript, C, and C++, a for loop is structured in the following way:
- Initialization (
i = 0): The loop variable is initialized. - Condition (
i <= 5): The loop continues as long as this condition is true. - Increment (
i++): The loop variable is updated after each iteration.
The correct syntax is:
(D) for (i = 0; i <= 5; i++).
This will start the loop with i = 0, and it will run as long as i is less than or equal to 5, incrementing i after each iteration.
Correct Answer: D) for (i = 0; i <= 5; i++)