tags:

views:

40

answers:

4
 int main()
  {

   int Count, Sum = 0;
   int Group[10];

    cout << "-303 to stop\n";

     for(Count = 0; Count < 10; Count++) {
     cout << "Enter a value: ";
     cin >> Group[Count];
       if(Group[Count] == -303)
     break;
     }

     int T;

      for(T = 0; T < Count; T++)
      Sum += Group[T];

      for(T = 0; T < Count; T++)
      cout << "Value[" << T << "]= " << Group[T] << endl;
    }

How can I change each of the values from this array? Suppose I want to multiply each value by 2 for example.

+1  A: 

Well, just like you can read from Group[T] to print it on the screen, you can assign to Group[T].

So, for example:

for(T = 0; T < Count; T++)
    Group[T] *= 2;
Ben Voigt
A: 

I take it you mean the array Group?

  for(T = 0; T < Count; T++)
   Group[T] = Group[T]*2; // or Group[T] *= 2;
Femaref
A: 
for(int i = 0; i < Count; i++)
{
    Group[i] *= 2;
}
Mandelbrot
A: 

You're already doing "something" with each group[T] item in your code:

for(T = 0; T < Count; T++)
  Sum += Group[T];

So to make a change to so something different, the loop (for) can stay the same, but have the content change so that it does something new, rather than add each one to sum:

for(T = 0; T < Count; T++)
  Group[T] = Group[T] * 2;
eruciform