Answers for "loop over an array c++"

C++
2

lopping over an array c++

for (int i = 0; i < arr.size(); ++i){
//use if we explicitly need the value of i
cout << i << ":t" << arr[i] << endl;
}
for (int element : arr){
//modifying element will not affect the array
cout << element << endl;
}
for (int &element : arr){
//modifying element will affect the array
cout << element << endl;
}
Posted by: Guest on May-25-2020

Code answers related to "loop over an array c++"

Browse Popular Code Answers by Language