loops are used for performing same task repeatedly and array were used for grouping similar type elements. In general we perform same operation on all array elements like taking input or printing them. And for doing this we have to use loops. It is not mandatory to use loops for each and every array. but loops make you program very short and readable.
Why are arrays and loops well suited for each other?
Arrays are used to store info of the same type and loops make it easier to repeat a block of statements.
if ud like to perform the same task for all the elements in an array you can use a loop instead of manipulating each and every item in an array individually.
reliable web hosting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment