#include <stdio.h>
int main(void){
int row, col, mat[row][col], i, j, high = 0, sec_high = 0;
scanf("%d %d", &row, &col);
for(i = 0; i < row; i++)
for(j = 0; j < col; j++){
printf("\nEnter %d row %d col.\n", i, j);
scanf("%d", &mat[row][col]);
printf("%d \n", mat[row][col]);
}
for(i = 0; i < row; i++){
for(j = 0; j < col; j++){
if (high < mat[i][j]){
sec_high = high;
high = mat[i][j];
}
else if(sec_high < mat[i][j]){
sec_high = mat[i][j];
}
printf("i%d j%d h%d s%d mat%d\n", i, j, high, sec_high, mat[i][j]);
}
}
printf("The second highest number is: %d.", sec_high);
}
What I am trying to do over here is simply to take out the second highest number from a matrix. Every thing is fine until The 3rd printf
come where I am getting random numbers huge numbers. Which is totally unexpected since I have already printed those numbers once while inputting and every thing was fine. So what is the logical error over here?