0
How can i increase an element's value in an array using a for loop and cout the new array?
2 Antworten
+ 2
something like this? :
int a[3] = {4,7,8};
for(int i = 0; i < 3; i++)
{
a[i] += i;
}
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;