Finding Smallest Number in Array Help!

Hi , I was assigned to create a program that has a 10 x 8 two dimensional array and fill it with random numbers in the range 50 to 70 inclusively.( Got That part down). The second part is to make function named findSmallest that will find and print, appropriately labeled, the smallest number in the array.

I cant seem to get it working. The code for finding the smallest give me some weird number

Help is greatly appreciated!

Here my Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//Assignment 18 Program 2
#include <iostream>
using namespace std;

int main()
{
 
    int row=0;
    int col=0;
    int ArrayGrid [9][11];
    srand(time(NULL));
    

    for(row=1; row<9; row++)
    {          
        for(col=1; col<11; col++)
        {       
            ArrayGrid  [row][col]= rand() % (1 + 70) ;
        }
         
    }
    
//PrintArray

    for(row=1; row<9; row++)
    {          
        for(col=1; col<11; col++)
        {       
            cout << ArrayGrid[row][col] << "\t";
                
        }     
              
        cout << ""<<endl<<endl;               
    }

//findSmallest   

int smallest = ArrayGrid[row][col] ;
    for ( int i=1;  i < sizeof(ArrayGrid)/sizeof(ArrayGrid[0]);  ++i )
        if ( ArrayGrid[row][col] < smallest )
             smallest = ArrayGrid[row][col] ;

    cout << "The Smallest Number In The Array Is: " << smallest << endl <<endl;


system ("pause");
return 0;
}
Well, that would be because... You're not actually going through elements of the array. Row 25 through 34 works fine- why not just do something like that?
how would u do that? would mind showing me in my code?
Topic archived. No new replies allowed.