function in array...

.i got a problem in running this pgrm.supposely this coding is to print the output of random frequency and number according to the array size.but it is not work it..


#include<iostream>
#include<cstdlib>
using namespace std;
void fill(int array[],int array_size);
void frequency (int b);
main()
{
int z,y[20]={};
srand(time(0));
cout<<"number:\n"<<fill(y,20);
cout<<"frequency\n"<<endl;
cin>>frequency(z );

}


void fill(int array[],int array_size)
{
int number;
for(number=0;number<array_size;number++)
cout<<array[number]<<" ";}

void frequency (int b)
{
int x;
x=rand()%5+1;
cout<<x;

}

Last edited on
I see quite a few issues. I'm not sure which is is making it "not work it".

The "fill" function doesn't fill anything, it outputs numbers. I would expect this to "fill" the array with something.

The array is uninitialized when you start outputting it.

the frequency function has a formal parameter, b, but you don't do anything with it. You just output a random number from 1 to 6.

fill and frequency both return a void type, yet you are trying to cout it. You can't cout a void.

You also can't cin >> frequency. What do you expect that to do? It will first cout a random number in the frequency function and then cin to the returned void which is nothing and will give an error.




thank you for your explaination...but sorry,,i don't really get your point.can you explain more.
Topic archived. No new replies allowed.