<< split from here >>
how can i make this code to display how meany times a number appears in the array.. example... if there are 5 number 3 it will display this with asterisks..
3 *****
and so on for each number... here is my code... i almost have it
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int num_generated[100];
int count(int x);
int main(void){
int j,m,a,b,ans,x=0,z=0;
srand(time(NULL));
for(j=0;j<100;j++){
num_generated[j]=rand()%11;
printf("%d. %d\n ",x, num_generated[j],x++);
}
printf("\nhere is how meany times each number exist on the array");
for(a=1;a<=10;a++){
ans= count(a);
printf("\n%d %d",z,a,z++);
for(b=1;b<=ans;b++){
printf("*");
}
}
}
int count(int x){
int cnt,j;
for( j=0; j< 100;j++){
if(num_generated[j]==x)
cnt++;
}
return cnt;
}