- #1
USN2ENG
- 108
- 0
Homework Statement
Just as a background this is my first time ever learning to program. I am in an engineering C++ class. I had to write a program that took in ten random numbers and then found the mean median and mode. I got the first two and was able to figure out how to sort correctly. But now I am trying to set up a second array to count the number occurrences of the first array and I am getting a couple errors. I googled the errors but I am still not sure what it exactly means.
The Attempt at a Solution
My code snippet (if you need more, just let me know, I just didnt want to fill the whole page up):
int fakearray[10]={1,1,1,1,1,1,1,1,1,1};
int temp = 0;
for(int y=0; y < 10; y++)
{
temp=Bubble[y];
for(int x=0; x<10;x++){
if(Bubble[x]==temp){
int fakearray[y]= fakearray[y]++; //This is where all the errors are pointing
}
}
}
The errors I am getting:
error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2440: 'initializing' : cannot convert from 'int' to 'int []'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Thanks to anyone that can help point me to the right path!