Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //function prototypes
- int smallestIndex(int listArray[], int Size);
- void main()
- {
- int listArray[10] = { 20, 67, 4, 38, 1, 63, 28, 95, 10, 7 };
- int location = smallestIndex(listArray, 10);
- cout << "The location of the smallest number in the list = " << location << endl;
- }
- //Function smallestIndex
- //smallestIndex finds the smallest number in the listArray and returns it
- int smallestIndex(int listArray[], int Size)
- {
- int i;
- int minIndex = 0;
- for (i = 1; i < Size; i++)
- {
- if (listArray[minIndex] > listArray[i])
- {
- minIndex = i;
- }
- }
- return minIndex;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement