answersLogoWhite

0


Best Answer

foreach can simply replace for loop. for ex in perl, if you need to copy display an array, it will take only foreach $var(@arr). then print $var. no need of incrementing the index of array like for loop.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

when there is a need to do initialisation,condition check and increment in the same

statement then for loop is used.otherwise while loop is used.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the advantages of using a foreach loop over a for or while loop for processing list elements?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Disadvantages transaction processing Disadvantages of transaction processing systems Advantages of using transaction processing system What are the advantages of transaction processing What ar?

disadvantages of transaction processing system


What are the advantages of using digital technologies for signal processing?

it links the world...


What are the advantages of using central processing unit?

Computers don't work without a CPU, so there are no advantages or disadvantages.


What are some advantages to using word processing software to prepare a resume?

hello :D IT IS AWSOME


What are the advantages of using a third-party data processing service?

The biggest advantage to using a third party data processing service is that it can streamline your data processing. For example, an insurance company that uses a data processing service can use it to process claims quickly and efficiently.


Is it mandatory to use array in foreach loop C-sharp can foreach be used without array?

Foreach is for an IEnumerable, not just an array (unless you are using C# 1.1 or earlier). A collection (List, Dictionary, etc) can also generate a sequence from foreach-statement. In fact, if you have a class that is NOT an array, but it implements all the required methods of IEnumerable, it may be applied as:public class Storage: IEnumerable {...}Storage myStorage = new Storage();...Foreach (Thing stuff in myStorage){...}


Advantages of using computer for information processing?

It's major advantage is that it can be used anywhere, any time for any work.


What are Advantages of using cryogenics?

Cryogenic Processing of metals (i.e. metals frozen to low temperatures) show more resistance to wear


How do you count the vowels in a string using PHP?

build an array of vowels then do a foreach on the array and then explode the string on the array value and the answer is -1 of the result


What are the advantages of using ict for a leaflet?

advantages of using ICT


Advantages of using Sat Nav?

what is the advantages of using a sat nav.


What are advantages and disadvantages of using a heligimbal?

what are the advantages and disadvantages of using a heligimbal