Please describe your problem further. What does a bad number look like?
Some problems:
Line 20: average will be a double, but probably not the way you intend. You are performing an integer division and then putting it in a double, which means you won't have any fractional data. You must also cast either the divisor or dividend to a double on this line.
Line 28: Initialize swap to 1. Right now it is probably initialized to whatever happens to be hanging out in the stack space (which you'd have to be lucky for it to be 1), and your loop would rarely get entered.
You seed it by calling std::srand() once in your program preferably in main() and by feeding it a different value each time the program is run. To accomplish this, most people feed it time().
Yes, what I meant was that your current calculation won't give you the average you probably want. In addition to declaring average as double, you must also be sure that you perform real division. Since total and size are both integers, C++'s behavior is to perform integer division (12 / 5 = 2, but what you probably want is 2.4). To force it to perform real division, you can cast either the divisor or dividend to double: double average = total / (double)size;
that outputs more accurate numbers but it still gives bad numbers at the start.
and if the random number is a "55" I want it to add a one to the 55th place in the array, because I have to calculate which number was produced the most and least. i'm not sure if it still adds one to the 55th spot in the array.
OH. I didn't realize that's what you're trying to do. Why is array size 500 if it is to contain the counts for only 100 numbers?
Also, when you sort those counts you will lose the association with the number each count represents. It is a confusing approach.
well I want it to loop 500 times and each spot in the array "should" have a value of 5 but since it is random some will have more or less and I have to figure that out.
but I just don't see why my random numbers are out of the scope of 1-100.