0

How can i increase an element's value in an array using a for loop and cout the new array?

18th Mar 2017, 2:59 PM
Khalil R Ziadeh
Khalil R Ziadeh - avatar
2 Antworten
+ 2
something like this? : int a[3] = {4,7,8}; for(int i = 0; i < 3; i++) { a[i] += i; }
18th Mar 2017, 3:04 PM
Max_N
Max_N - avatar
0
and following on from Max_N to cout the array something like: for (int i = 1; i < 3; i++) { cout << a[i] << " "; // this can also be placed in the first loop } cout << endl;
18th Mar 2017, 4:26 PM
Shane