Ask Question
31 May, 11:20

Assuming arrayName is the name of an array and identifier is a name of a variable that has the same data type as the array elements, which of the follow is the correct syntax for the range-based for loop?

a) for (dataType identifier : arrayName) statements

b) for (dataType : arrayName) statements

c) for (identifier : arrayName) statements

d) for (arrayName : dataType identifier) statements

+4
Answers (1)
  1. 31 May, 12:44
    0
    The answer is "Option a"

    Explanation:

    Range-based for loop performs a sequence for a loop. It's more accessible as the conventional loop, for example, all components in the array, running more than a range of possibilities. In the given question "option a" is correct because it follows the correct syntax and other choices were wrong, which can be described as follows:

    In option b, It's not correct, because in this code the range declaration is wrong. In option c, It is wrong, because in this code the datatype is missing. In option d, It is illegal syntax, that's why it is wrong.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assuming arrayName is the name of an array and identifier is a name of a variable that has the same data type as the array elements, which ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers