The errors boil down to the RationalInfo() function, even though you are not calling
it from anywhere, the compiler wants it to be OK, so fix it first or remove it if don't need it
int RationalInfo (int initialArray[]<strong>[MAX]</strong>)
{
<strong>// You still need to declare the variables a and b here</strong>
int quotient, remainder;
float value;
for (int i = 0; i <setArray; i++)
{
for (int j = 0; j < MAX; j++)
{
initialArray [i+2][j] = initialArray [i][j] / initialArray [i+1][j];
quotient = a/b <strong>;</strong>
remainder = a%b <strong>;</strong>
value = a/b <strong>;</strong>
}
}
<strong>// You need to return something from this function</strong>
return ???
}
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395
Also, you indexing into the array at [i+1] and [i+2] will give you odd results for the first setArray-1 rows, and will go out of bounds in the last row.
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228
Check your function prototype, versus how you've defined it. When you fix the prototype, you'll probably find that you should have put the constant declarations before the prototypes, since they use one or more of the constants.
It's also generally considered bad form to use global variables (your array) - that should be declared in main( ) and be passed as a parameter to the functions that need to access it.
And just what is this program supposed to be doing?
vmanes
Posting Virtuoso
1,914 posts since Aug 2007
Reputation Points: 1,268
Solved Threads: 228
A couple of things to fix ...
int main()
{
srand(time(NULL));
int sizeArray = rand () % MAX;
// at this point, sizeArray may very well be zero,
// probably you don't want that, so add a check against
// that condition ...
<snip>
}
int RationalInfo (int initialArray[][MAX], int size)
{ <snip>
for (int j = 0; j < size; j++)
{
// if initialArray[i+1][j] is zero, your program will fail here,
// you must not divide by zero, ever
initialArray[i+2][j] = initialArray[i][j] / initialArray[i+1][j];
// the same thing with % operator, initialArray[i+1][j] must not
// be zero here
initialArray[i+3][j] = initialArray[i][j] % initialArray[i+1][j];
}
return 1;
}
mitrmkar
Posting Virtuoso
1,809 posts since Nov 2007
Reputation Points: 1,105
Solved Threads: 395