two dimensional array help
Hi all hope someone can give me a few pointers.
This is what I want to achieve but don't understand.
I want to return the two dimentinal array position of the largest value in a sequence of numbers.
So here is my code so far which does not return the correct results.
Code:
#include <stdio.h> //preprocessor directive to include stdio
#define NUMROWS 3 //preprocessor defines
#define NUMCOLS 3
int main() //ep to main
{
int i, j; //for loop vars
int val[NUMROWS][NUMCOLS] = {1,2,3,4,5,6,7,8,9};
int maxnumpos = val[0][0];
for(i = 0; i < NUMROWS; i++) //start outer loop
{
for(j = 0; j < NUMCOLS; j++)
if(val[i][j] > maxnumpos)
maxnumpos = val[i][j];
}
printf("the maximum value in the array is %d & is stored at postion %d %d\n", maxnumpos, val[i][j]);
}
Can anyone give me some pointers to begin to understand how to deal with this scenario, whether it is code examples or a text to read
thanks in advance for your help
:confused: