# How do I find the smallest number in an array

Page 1 of 1

## 2 Replies - 1015 Views - Last Post: 30 October 2013 - 09:21 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=332888&amp;s=eb8905a4c9a53b37e7416f7c8ed018ff&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 cathysd

Reputation: 0
• Posts: 8
• Joined: 09-May 13

# How do I find the smallest number in an array

Posted 30 October 2013 - 08:09 PM

I need help trying to find the lowest number in array ?? but I cant figure out what I doing wrong???? or is there a more simple way to go around this without an array?

```#include <iostream>
using namespace std;
int lowestNum(int arr[], int size);
int main ()
{
int howmany[100];
int inpnum;
int lowest_Num;
int sum = 0;
cout << "how many numbers would you like to know the sum of? "<< endl;
cin >> howmany[100];
for (int i =0; i < howmany[100]; i++)
{
cout << "Enter an integer: " <<endl;
cin >> inpnum;
lowest_Num = lowestNum(howmany, 100);
sum = sum + inpnum;
}
cout << "The sum is " << sum<< endl;
cout << "the lowest integer entered is " << lowest_Num << endl;

system ("Pause");
return 0;
}

int lowestNum(int arr[], int size)
{
int  lowestNum =arr[size];
for (int i =0; i < arr[size]; i++)
{
if (arr[i] <lowestNum)
{
lowestNum = arr[i];

}
return lowestNum;
}
}

```

Is This A Good Question/Topic? 0

## Replies To: How do I find the smallest number in an array

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 917
• Posts: 2,358
• Joined: 28-March 11

## Re: How do I find the smallest number in an array

Posted 30 October 2013 - 08:21 PM

Please use a more descriptive topic title than "Help!". Imagine everyone created topics titled help, it would be impossible for someone to pick a thread to help with, or for someone to search the boards for a similar problem. Topic renamed....

### #3 eker676

• Software Engineer

Reputation: 379
• Posts: 1,833
• Joined: 18-April 09

## Re: How do I find the smallest number in an array

Posted 30 October 2013 - 09:21 PM

Line 11:
```cin >> howmany[100];
```

That is not correct. Maybe something like this?
```int howmany = 0;
cin >> howmany;
```

And what is lowestNum()? If you have sequential (one-after-the-other) input, you can keep track of the lowest value and update it when you come across a lower value. Rough pseudo code.
```int lowest = <first value>