### Array

If a problem says write the code to create two arrays for storing the number of students at each age.
-studentDistrib for studentAge
-theirStudentDistrib for theirStudentAge

is it double studentDistrib[studentAge]
and
double theirStudentDistrib[theirStudentAge]

then if i want to update the elements of studentDis and theirStudentDis

for(int student=0; student<studentDistrib; student++)
{
double age =0;
cout<< "put age ";
cin>>age;
cout<<studentDistrib[student]<<" is "<<age;
}

You question sounds confusing to me. Are you sure you are reading it correctly?

I could see maybe an array for the number of students in each age group

and then another array for the names of students based off the the age group array.

That code you have up there would not update an array's element either way.

This would be a simple example on updating a single element of an array

 ``12345678910111213141516171819202122232425262728`` ``````// arrays example #include using namespace std; int billy [] = {16, 2, 77, 40, 12071}; int n; int main () { cout << "The original Array is: "; for ( n=0; n<5 ; n++){ cout << billy[n] << " , ";//print out original array's elements } cout << "\n"; for ( n=0 ; n<5 ; n++ ) { billy[n] = billy[n] + 1;//adding 1 to each element in the array } cout << "The updated Array is: "; for ( n=0; n<5 ; n++){ cout << billy[n] << " , ";//print out the udpated array's elements } return 0; }``````
Topic archived. No new replies allowed.