Help with array tutorials
Hello there ! I have been reading the tutorials for only the past 2 days whenever I had free time and I really like them, I'm even ordering the first two books recommended.
My programming skills are 0 but I really want to learn, I'm currently studying business in university and I believe knowing how to program will be very useful.
Even though the tuts are pretty simply to follow I have some doubts about when some code is used and whats the difference (like structures and unions), but I really got annoyed with the array code:
Code:
#include <iostream>
using namespace std;
int main()
{
int x;
int y;
int array[8][8]; // Declares an array like a chessboard
for ( x = 0; x < 8; x++ ) {
for ( y = 0; y < 8; y++ )
array[x][y] = x * y; // Set each element to a value
}
cout<<"Array Indices:\n";
for ( x = 0; x < 8;x++ ) {
for ( y = 0; y < 8; y++ )
cout<<"["<<x<<"]["<<y<<"]="<< array[x][y] <<" ";
cout<<"\n";
}
cin.get();
}
- First I don't get why the for loop is being declared twice.
- Second doubt I have is why does the second bracket (y) loop differently to x? I know it has something to do with x for loop being defined with {} but I don't get the actual difference.
Sorry to disturb with my noobness, its just if I don't get this simple concept I'm never going to move on !
And if this isn't a help forum for newbies like me I would appreciate a link to a forum where I can get help!
Thanks in advance!