cHey guy can anyone help me to solve this question because i am begginers i am so sure to use array

C++ write a program to find smallest of 30 integer using array

Thanks

## All 3 Replies

Yes, make an array and make one single integer variable.
Put the first variable from the array in the single variable and start looping.
If the next variable is LOWER than the the one in the single variable, replace it.
When you get to the end of the loop, the lowest value will be in the single variable.

The program will be

include <iostream>
include <cstdlib>

using namespace std;
int i;
int array[30];
int odd;
int max;
int counter;

int main()
{
for (int j = 0;j<30;j++)
{

``````    i = rand() % 101;
array[i]=i;

}

for (int k = 0; k < 30 ; k++)
{
cout << array[k] << " ";

}

for (int l = 0; l < 30 ; l++)
{
odd = array[0];
max = array[0];
if (array[l] % 2 != 0 && array[l] > max)
{
odd = array[l];
max = array[l];
}
if (array[l] % 2 == 0)
++counter;

if (array[l] % 2 == 0 && array[l] > max)
{
for (int m = 0; m < counter ; m++)
cout << array[m];

}
}

return 0;
``````

}

Regards,