0

im trying to show what is stored in arrays, basically to make sure my program is working fine, i have got it to print which element in the array it is, but how do u access the array and show what value is stored in it. my code is basically

for(int i = 0; i < 16; i++) 
            {
                for(int j = 0; j < 60; j++)
                {          
                    cout << endl << "string " << i << "weights " << j;  
                }
            }

i know this will only print the value of whatever j is. not what is stored in element j.

any help will be greatly appreciated?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Freaky_Chris
0

im trying to show what is stored in arrays, basically to make sure my program is working fine, i have got it to print which element in the array it is, but how do u access the array and show what value is stored in it. my code is basically

for(int i = 0; i < 16; i++) 
            {
                for(int j = 0; j < 60; j++)
                {          
                    cout << endl << "string " << i << "weights " << j;  
                }
            }

i know this will only print the value of whatever j is. not what is stored in element j.

any help will be greatly appreciated?

This is most confusing, are you saying you have 2 arrays called i and j as well as using i and j as loop counters!!!! Here's an example i suggested you look through it

int age[] = {3, 67, 234, 34};
for(int i = 0; i < 4; i++) {
        cout << "Age: " << age[i] << std::endl;
}

Chris

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.