How do I find the maximum and minimum element of a two dimensional array? Is my program correct?

int main ()
{
int a [4][3];
int max,min;
for (int i=0;i<4;i++)
for (int j=0;j<3;j++)
cin>>a[i][j];

max=a[0][0]; //IS THIS PART CORRECT? OR SHOULD I ASSUME MAX AND MIN ARE ZERO?
min=a[0][0];

for (int c=0; c<4;c++)
for (int d=0;d<3;d++)
{
if (a[c][d]>max)
max=a[c][d];

if (a[c][d]<min)
min=a[c][d];
}

cout<<"max="<<max<<endl;

cout<<"min="<<min<<endl;

return 0;
}


It's correct :)
Thank you :D !
Topic archived. No new replies allowed.