A
Code:
int array[2][4]; //assume that I already have values in the array here
int i;
int j;
int max=data[0][0];
int min=data[0][0];
int locationmax=0;
int locationmin=0;
for(i = 0; i < N; i++)
for(j=0;j<4;j++)
if(j==2&&array[i][j]>max)
{
max=array[i][j];
locationmax=array[i][1];
}
for(i = 0; i < N; i++)
for(j=0;j<4;j++)
if(j==2&&array[i][j]<min)
{
min=array[i][j];
locationmin=array[i][1];
printf("Max is %d number is%d\n",max,locationmax);
printf("Minimum is %d number is %d\n\n",min,locationmin);
}
Can somebody tell me why it work's with finding the max value, but not with the min value. My program saves 0 as min and 1 as locationmin?