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
| #include <iostream>
using namespace std;
int x[] = {20, 23, 45, 11, 62, 34, 23, 47, 11, 20, 15, 17, 36, 29, 30, 23, 14, 56, 20, 11, 62, 11};
int main(){
int t=22,count;
cout<<"Total number in the array is " <<t<<endl;
int highest, smallest;
highest=x[0];
for (count=1; count<t; count++){
if (x[count]>highest)
highest=x[count]; }
cout<<"The highest number is "<<highest<<endl;
smallest=x[0];
for (count=1; count<t; count++){
if (x[count]<smallest)
smallest=x[count]; }
cout <<"The smallest number is "<<smallest<<endl;
int average=0,a;
float d=22,sum;
for (a=0; a<22; a++){
average+=x[a];}
sum=(average/d);
cout<<"Average of all the numbers in the array is "<<sum<<endl;
cout<<"\nNumbers in the array that is duplicated"<<endl;
int k=0, l, m, n=0, p=0;
int h;
for (int i=1; i<t; i++)
{
bool matching = false;
for (int j=0; (j<i) && (matching == false); j++)
if (x[i] == x[j]) matching = true;
if (!matching) cout<<x[i]<<"="<<endl;
l=x[k];
while (p<t)
{
m=x[p];
if (l==m)
{
n=n+1;
}
p++;
}
k++;
p=0;
n=0;
}
} |