#include <iostream>
#include <conio.h>
usingnamespace std;
int main ()
{int x,y,c,d,e,i;
int b[100];
int a[100];
for (y=0;y<3;y++)
{
for (i=0;i<2;i++)
{if (i==0)
{cout <<"X coordinate"<<endl;
}
else
{cout <<"Y coordinate"<<endl;
}
cin>>a[i];
}
b[y]=a;
}
for (x=0;x<3;x++)
{cout<<b[x]<<endl;
}
return 0;
}
But ,it says "invalid conversion from 'int*' to 'int' So,I changed b[100] to *b[100] ,I don't really know what that does though.
Now, I figured,it should run fine, but it prints the last value for "x coordinate" three times.
So:
X coordinate 1
Y coordinate 2
X coordinate 3
Y coordinate 4
X coordinate 5
Y coordinate 6
5
5
5
A * character defines a pointer. I believe you are probably not looking to dynamically allocate memory for your array since you already seem to know what size you want.
If you want to access the 10th "b" element of the 2nd "a" element you could use (remember array elements are zero-based!): int some_value = myArray[1][9];
OK.
I was looking for something like this :--
B[y]= a[i]
So, for every different value of y, there is an array.
So if there are nine values for y, there are nine different arrays.
With multidimensional arrays, I'd have to make mine dimensions.
If you want to access the 10th "b" element of the 2nd "a" element you could use (remember array elements are zero-based!): int some_valuemyArray[1][9];
I'm not sure this makes sense.
int some_valuemyArray[1][9];
is declaring another, separate array with one row and nine columns.
To access an element of the first array, it would be something like
cout << "second row, tenth column value is " << myArray[1][9];
Did it. Had to look up a few tutorials on multidimensional arrays .Initially I did this:int i [2][2][2][2][2]; to create 5 dimensions. Looked up some videos,and the final code is: