As part my lab test this upcoming Tuesday, we're required to be able to do this question, otherwise we won't be able to do the real exam!
Here is the code :
* This program finds the range between highest and lowest value of a 2-D array */
#include <stdio.h>
#define NROW 3
#define NCOL 3
int main(void)
{
/* declare needed variables or constants, e.g. */
int ar[NROW][NCOL];
int number;
int rows, columns;
/* prompt for the user to enter nine positive integers to be stored into the array */
for ( rows = 0 ; rows < 3 ; rows++ )
{
for ( columns = 0 ; columns < 3 ; columns++ )
{
printf("Please enter 9 numbers " );
scanf("%d", &number);ar[NROW][NCOL]
/*store the number temporarily*/
number = dispArray( ar[NROW][NCOL] )
}
}
/* call the disp_arr(...) function */
dispArray()
/* call the highest(...) function */
/* call the lowest(...) function */
/* display the range between highest and lowest number
/* Return to the operating system */
}
void dispArray( a[][] )
int rows, columns, a[][];
for ( rows = 0 ; rows < 3 ; rows++ )
{
for ( columns = 0 ; columns < 3 ; columns ++ )
{
printf( "%d\t", a[][] );
}
printf("\n");
}
return a[][];
/* Write a function where a[][] is the 2-D array
Print the entire array to the screen. */
At the moment I just need to know how to print the array to the screen. My function and the way I call it in the main
are obviously wrong.
I'm really bad at functions especially when it comes to passing arguments...which I have no idea what is it too.
Any help would be appreciated! Thanks! Sam