hi
i tried to do this q but i stuck in the middle of writing codes
Write a program that creates an array dynamically whose pointer must not change, initialize the array to random values between 0 and n (inclusive) using rand () where n is a value entered by the user, then pass the array to a function that takes an array of integers, its size and n and returns the value that was repeated more than other values. The function must use an array of n elements that is used to store the number of occurrences of a specific value, for example location 0 tells you how many times 0 appeared in the passed array, location 1 tells you how many times 1 appeared in the passed array and so forth.
#include <iostream>
#include<ctime>
using namespace std;
int fun( int a[], int size, int n)
{
int *p= new int[n+1];
if (p==NULL)
{
cout<<"errer!"<<endl;
exit(1);
}
for (int i=0;i<size;i++)
{
p[i]=0;
}
for (int j=0;j<size;j++)
{
p[a[i]]++;
}
}
void main()
{
cout<<"please enter a number\n";
int n;
cin>>n;
int *const p= new int [5];
srand(time(0));
for(int x=0;x<5;x++)
{
p[x]=rand()%(n+1);
}
}