c++ loop an array code example
Example 1: loop through array c++
for(int i = 0; i < 4; i++) {
cout << cars[i] << "\n";
}
Example 2: how to add elements in an array in for loop c++
int * myVar = new int [5];
for (int i = 0; i < 5; i++)
myVar[i] = i
// 0 1 2 3 4 myVar in the array
// delete stuff *optional*
delete [] myVar;
myVar = NULL;
// free up memory declared on the stack