I'm trying to make that finds and prints out the largest numbers compared to all their neighbors. But i cant think of an efficient function that checks them. Please help I'm trying to get this off my things to do >_>
.
/* This program uses multidimensional arrays to find the largest
* number compared to their neighbors. I call this program multidimensional.c */
#include <stdio.h> /* librarys */
#include "genlib.h"
#define size 3 /* constants */
void displayMatrix(int intArray [size][size]);
main()
{
/* the intArray values you may change the values is you wish */
int intArray[size][size]=
{
{22,9,1},
{12,8,3},
{4,0,12}
};
}
void displayMatrix(int intArray [size][size])
{
printf("hello");
int row, column, x;
int num[size];
x=0;
getchar();
}
1) don't use #define to make constant. Use constants instead:
1 2
//#define size 3 // bad
staticconstint size = 3; // good
2) main should return an int. You don't have it returning anything:
1 2
//main() // bad
int main() // good
3) What jsmith is saying is, your displayMatrix function is never being called, therefore that code is never being run. Any code you have written inside of displayMatrix will only execute when you call it:
/* This program uses multidimensional arrays to find the largest
* number compared to their neighbors. I call this program multidimensional.c */
#include <stdio.h> /* librarys */
#include "genlib.h"
staticconstint size = 3; /* constants */
void displayMatrix(int intArray [size][size]);
int main()
{
/* the intArray values you may change the values is you wish */
int intArray[size][size]=
{
{22,9,1},
{12,8,3},
{4,0,12}
};
displayMatrix(intArray);
return 0;
}
void displayMatrix(int intArray [size][size])
{
printf("hello");
int row, column, x;
int num[size];
x=0;
getchar();
}