Answer:
item based for loop is used to iterate items in a collection .it is useful to apply some operations on item. Index based for loop is used to execute some logic repetitively. While loop also useful to execute a logic repetitively
Step-by-step explanation:
item based for loop is used to iterate items in a collection .it is useful to apply some operations on item. Index based for loop is used to execute some logic repetitively. While loop also useful to execute a logic repetitively
in c#.net , following example explains this
using system;
void main(){
String[] names=new names[20];
int counter=0;
//index based for loop
for(int i=0;i<20;i++){
console.read(names[i]);
}
//item based for loop
foreach(string s in names){
console.writeline(s);
}
//while loop
while(counter<20)
{
console.read(names[counter];
counter++;
}
}