MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
How do you write a for loop?
A
for (int i = 0; i < 21) {}
B
for (int i = 0; i++) {}
C
for (int i = 0; i < 21; i++) {}
D
for (i) {}
Explanation: 

Detailed explanation-1: -For Loops using range() start states the integer value at which the sequence begins, if this is not included then start begins at 0.

Detailed explanation-2: -A for loop is a type of loop that repeats a block of code a specific number of times. The range() function has a few default settings: The initial value of i is 0.

Detailed explanation-3: -"i” is a temporary variable used to store the integer value of the current position in the range of the for loop that only has scope within its for loop. You could use any other variable name in place of “i” such as “count” or “x” or “number".

There is 1 question to complete.