Not getting the array index

Hi

I am trying to print the array element by taking the input from the user,,but when i am trying to print the array index it giving some garbage values for line

for(int row=0;row<=1;row++)
{
for(int col=0;col<=2;col++)
{
cout << "Enter"<<arr[row][col]<< "value"; // this line is giving garbage values
cin >> arr[row][col];
}
}

can you post all your code please.
It's obviously giving garbage values because you're printing out each index before you give it a value. You have probably created the array somewhere and never filled it. What you then do in that for-loop is print out the first element, which is just garbage because you havent filled it, then you fill it, then you print out the next element, and then you fill it and so on and so on. Wrong order.

Should be :
1
2
cin >> arr[row][col];
cout << "Enter"<<arr[row][col]<< "value"; // this line is giving garbage values 

Topic archived. No new replies allowed.