reading and putting numbers in an array

the code works just fine until it reaches the output of finding the small number then it just stops can anyone help me out me out

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include<iostream>

Using namespace std;



class group
{
public:
	int smallest();		// function to find the smallest element of the array
	int biggest();		// function to find the biggest element of the array
	int position(int);	// function which returns the position of the parameter value
						// (-1 if not in the array)
	void assignVals();	// function which asks the user for values to put in the array
	void printVals();	// function which prints the values in the array
	group();			// The default constructor,
						// every element of the array will be set to zero
	group(int);			// constructor which sets every element of the array to the parameter
private:
	static const int SIZE = 10;  // Initializes the constant SIZE to 10 
	int members[SIZE];			 // an array of integers
	
};



group::group()
{

	for (int i = 0; i < 10; i++)
	{

		members[i] = 0;

	}

}

group::group(int n)
{

	for (int i = 0; i < 10; i++)
	{

		members[i] = n;

	}
}

void group::printVals()
{

	cout << "The numbers you entered are : ";
	for (int i = 0; i < 10; i++)
	{

		cout << members[i] << " ";

	}

}

void group::assignVals()
{

	for (int i = 0; i < 10; i++)
	{
		cout << "Enter a number :";
		cin >> members[i];
	}

}

int group::position(int n)
{

	int pos;

	for (int i = 0; i < 10; i++)
	{
		if (members[i] == n)
			return i;
		else
			pos = -1;
	}
	return pos;
}

int group::smallest()
{
	int small;
	small = members[0];
	for (int i = 0; 1 < 10; i++)
	{
		if (small < members[i])
			small = members[i];
			
	}
	

	return small;
}

int group::biggest()
{
	int big;
	big = members[0];
	for (int i = 0; 1 < 10; i++)
	{
		if (big < members[i])
			big = members[i];
	}  

	return big;
}
int main()
{
	int num, pos;

	group numbers;
	group numbers2(5);

	numbers.printVals();
	cout << endl;
	numbers2.printVals();
	cout << endl;


	numbers.assignVals();
	cout << "Now for the next group" << endl;
	cout << "______________________" << endl;
	numbers2.assignVals();

	cout << "What number are you looking for? ";
	cin >> num;
	pos = numbers.position(num);
	if (pos == -1)
		cout << "The number " << num << " is not in the first group\n";
	else
		cout << "The number " << num << " is at position " << pos << " of the first group\n";

	pos = numbers2.position(num);
	if (pos == -1)
		cout << "The number " << num << " is not in the second group\n";
	else
		cout << "The number " << num << " is at position " << pos << " of the second group";

	cout << "The smallest value in the group is: " << numbers.smallest() << endl;
	cout << "The largest value in the group is: " << numbers.biggest() << endl;
   cout << "The smallest value in the second group is: " << numbers2.smallest() << endl;
cout << "The largest value in the second group is: " << numbers2.biggest() << endl;

	
	return 0;
}


Topic archived. No new replies allowed.