Jan 10, 2015 at 4:48pm UTC
Could you tell me where is the problem?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include <iostream>
#include <time.h>
#include <cstdlib>
#include <iomanip>
using namespace std;
int displayArray(int A[10][11])
{
int i,j;
cout<<" " ;
for (i=0;i<10;i++)
{
for (j=0;j<11;j++)
{
cout<<A[i][j]<<setw(5);
}
cout<<endl;
}
return 0;
}
int main()
{
int i,j;
int A[10][11];
srand(time(NULL));
for (i=0;i<10;i++)
for (j=0;j<11;j++)
A[i][j]=rand()%20;
displayArray(A);
system("pause" );
}
Last edited on Jan 17, 2015 at 5:22pm UTC
Jan 10, 2015 at 4:54pm UTC
Problems:
1. terrible formatting.
2. no identation.
3. Main problem: wherever you've typed <=
you need to replace with <
Jan 10, 2015 at 4:59pm UTC
thank you for your replying i will try to fix them
Jan 10, 2015 at 5:01pm UTC
it's just 3 you need to fix really :)
You're going beyond the range of your array.
Remember, if you've declared an array of size 10 you need to iterate from 0 to 9, which is why you just need the 'less than' and not 'less than or equal to' operator in your loop condition.
Jan 10, 2015 at 5:04pm UTC
thanks i will remember this forever :)