An array and subprogram problem

so basically i want a program that will give me the smallest number of an array , this was easy for me until i read that i must use a subprogram called "min"

this is the best i have done , i do not know how to fix it further
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
#include <iostream.h>
#include <conio.h>

int min1(int mn , int a)
{

mn=a[0];
for(int i=1;i<10;i++)
	{
		if(mn>a[i])
		{
			mn=a[i];
      }
	}
cout<<"Minimum number is: "<< mn << endl;
}


 void main()
 {
const int Numb = 10;
int a[Numb]; //10 elements
cout<<"Enter 10 values:"; //prompts user for 10 values.
for(int i=0;i<10;i++)
{
cout<< "\nEnter value: ";
cin>> a[i]; // puts values in array
}

      getch ();
      }




so yeah , some help would be great !
Last edited on
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
49
50
51
52
53
54
55
#include <iostream>


using namespace std;

int min1(int mn , int a[10])
{

mn=a[0];
for(int i=0;i<10;i++)
	{
		if(mn>a[i])
		{
			mn=a[i];
        }
	}
cout<<"Minimum number is: "<< mn << endl;
}

int max1(int mx , int a[10])
{

mx=a[0];
for(int i=0;i<10;i++)
	{
		if(mx<a[i])
		{
			mx=a[i];
        }
	}
cout<<"Max number is: "<< mx << endl;
}



 int main()
{

const int Numb = 10;
int a[Numb]; //10 elements
int min;
int max;


cout<<"Enter 10 values:"; //prompts user for 10 values.
for(int i=0;i<10;i++)
{
cout<< "\nEnter value: ";
cin>> a[i]; // puts values in array
}

min1(min,a);
max1(max,a);

}


Here i continue your program and i add and MAX NUMBER function.

Hope to helped you...
Yes you did very much thank you
i get it now
i didn't need the max but i have no problem in extra grades ,
Topic archived. No new replies allowed.