I am going through my C++ class assignments and Iam trying to figure out what the programs I wrote can do.
This is one about arrays.
Please explain under what circumstances I can use this.
Thanks.
// arrays_accessing using for loops.cpp : Defines the entry point for the console application.
//The loops works well coz they increment the variable for the user.And the user only needs to increment by one.
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
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();
//return 0;
}