Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

lopping over an array c++

for (int i = 0; i < arr.size(); ++i){
//use if we explicitly need the value of i
cout << i << ":	" << 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;
}
 
PREVIOUS NEXT
Tagged: #lopping #array
ADD COMMENT
Topic
Name
9+3 =