My project requires me to write a program that generates random numbers, maintain a running total of the numbers into categories (0-20, 21-40, 41-60, 61-80, 81-100) then plot the results on a histogram. This is what I have so far. I put the cout statements at the end to check the memory, but its not logging correctly, needless to say I'm lost.
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int test=0;
int count=0;
int data=0;
int avg=0;
int bin[5]={0,0,0,0,0};
srand(time(0));
cout<<"Please enter number of test values:\t";
cin>>test;
while (count<test)
{
data=rand()%100+1;
cout<<data<<"\t";
if (data<=1 && data<=20)
bin[0]++;
else if (data<=21 && data<=40)
bin[1]++;
else if (data<=41 && data<=60)
bin[2]++;
else if (data<=61 && data<=80)
bin[3]++;
else if (data<=81 && data<=100)
bin[4]++;
count++;
}