0
how to assign values to the first dimension in multi dimensional array then assign values to the second like (x,y) . then output
#include <iostream> using namespace std; int main () { int sum ; int x , y ; int z [x][y]; for (x=0; x<3 ;x++) { z[x]=1+x; cout << z[x]<<" "; } cout << endl; for (y=0 ; y<4 ;y++) { z[y]=2+y; cout << z[y] << " "; } cout << z[0][0]; return 0; }
1 Antwort
0
I don't understand your idea. But I just noticed a possibility for problem.
int x, y;
// these variables are uninitialized
// and contain garbage values.
int z[x][y];
// use of garbage values in array definition.