Hi, I am trying to create a c++ program for counting the number of occurrences in an array using 2 1-D arrays such that the first array contains the elements and the second array gives the count of the number of occurrences of each element in the first array. Unfortunately, whenever i try to find this program, it only involves just one array and the count just prints number of elements frequently occurring in a for loop. Could somebody please provide me the code? I would really appreciate the assistance.

you need to post your trials to help you ,no one can do your work for you

Try this (you do the definitions and declarations), I just thought this might work, didn't test it.

k=1;
    for(i=1;i<=n;i++)
        {kk=1;
         for(j=1;j<=n;j++)
            if(x[i]==x[j]) k++;
            y[kk]=k;}


     for(j=1;j<=n;j++)
        if(x[i]==x[j]) k++;
        y[kk]=k;}

Sorry, no lines 9,10,11.

k=1;
    for(i=1;i<=n;i++)
        {kk=1;
         for(j=1;j<=n;j++)
            if(x[i]==x[j]) k++;
            y[kk]=k;}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.