FINAL C++ 101 HELP PLZ!

I FIXED THIS MYSELF. HOW THE FUCK DO YOU DELETE THIS?
Last edited on
its unreadable!!! please use code tag!
One problem is that you don't initialize the values in frqAry.

And I agree with Burz666. The code is much easier to read if you use code tags.
Deleting the original post/entire threads goes against the spirit of this forum, sah. Unless, of course, the OP is a troll. :)

-Albatross
OP says (now with code tags included!):

The purpose of this lab is the have the user input 10 numbers (0-9) and the calculate how many times it occurs in the array. Also calculate which number occurs the most and the least. The max and min are fine.

Im getting weirdddd numbers... this is the output

_ARRAY_RANGER_
Enter 10 digits
Enter # (0-9)1
Enter # (0-9)2
Enter # (0-9)3
Enter # (0-9)4
Enter # (0-9)5
Enter # (0-9)6
Enter # (0-9)7
Enter # (0-9)8
Enter # (0-9)9
Enter # (0-9)9
0 occurs 1 times.<-WRong
1 occurs 1 times.
2 occurs 4197694 times.<-WTF?
3 occurs 1 times.
4 occurs -1821132599 times.<-WTF
5 occurs 32768 times.<-WTF
6 occurs 4197601 times.<-GOD DAMMIT
7 occurs 1 times.
8 occurs 1 times.
9 occurs 2 times.
2 occured the most.
4 occured the least.
Maximum=9
Minimum=1

Here is the program

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
#include <iostream>
using namespace std;

int input(int ary[],const int m){//Input integers to array
int value;
cout<<"_ARRAY_RANGER_"<<endl<<"Enter 10 digits"<<endl;
for(int i=0;i<m;i++){
cout<<"Enter # (0-9)";
cin>>value;
if(value>10||value<0){
cout<<"ERROR"<<endl;
}
else{
ary[i]=value;//Input if condition works
}
}
}
int freq(int ary[],int freqary[],const int m){//Calculate frequency in array
for(int i=0;i<m;i++){
freqary[ary[i]]++;//Make a separate array for frequency
}
}
void data(int frqAry[],const int m){//List select data
int least=0;
int most=0;
int max=0;
int min=10;

for(int i=0;i<m;i++){//Number occurs x times
cout<<i<<" occurs "<<frqAry[i]<<" times."<<endl;
}
for(int i=0;i<m;i++){//Calculates number occured most
if(frqAry[i]>=max){
max=frqAry[i];
most=i;
}
}
cout<<most<<" occured the most."<<endl;

for(int i=0;i<m;i++){//Calculates number occured least
if(frqAry[i]<=min){
min=frqAry[i];
least=i;
}
}
cout<<least<<" occured the least."<<endl;
}
int Min(int ary[],const int m){//Minimum number input by user
int MIN;
MIN=ary[0];
for(int i=0;i<m;i++){
if(ary[i]<MIN){
MIN=ary[i];
}
}
return(MIN);
}
int Max(int ary[],const int m){//Max number input by user
int MAX;
MAX=ary[0];
for(int i=0;i<m;i++){
if(ary[i]>MAX){
MAX=ary[i];
}
}
return(MAX);
}
int main(){
int Min(int[],const int);
int Max(int[],const int);
int input(int[],const int);
int freq(int[],int[],const int);
void data(int[],const int m);

int MAX,MIN;
const int max=10;
const int yax=10;
int array[max];
int frqAry[yax];

input(array,max);

freq(array,frqAry,max);

data(frqAry,max);

MAX=Max(array,max);
cout<<"Maximum="<<MAX<<endl;
MIN=Min(array,max);
cout<<"Minimum="<<MIN<<endl;
}
Topic archived. No new replies allowed.