Code:

     do{
                cout<<"No. of random numbers (-10-10): "<<endl;
                cin>>howmany;
                    if(howmany<1 || howmany >50)
                    cout<<"INVALID INPUT"<<endl;
            }while (howmany<1 || howmany>50);

        cout<<endl<<endl
        <<"The "<<howmany<<" random numbers from 1-50 are :"<<endl;

    srand(time(0));

        for (ctr=0,negativectr=0,positivectr=0; ctr<howmany; ctr++)
        {
            randnum[ctr]= rand() % 50-1;
            cout<<randnum[ctr]<<"\t";

            if (randnum[ctr] % 2 ==0)
                {
                    positive[positivectr]=randnum [ctr];
                    positivectr++;
                }

            else
                {
                    negative[negativectr]=randnum [ctr];
                    negativectr--;
                }

    {
        cout<<endl<<endl<<"There are "<<positivectr<<" positive numbers generated"<<endl;
    for(ctr=0;ctr<positivectr;ctr++);
    }
        cout<<positive[ctr]<<"\t";
    }

    cout<<endl;

    cout<<"There are "<<negativectr<<" negative numbers generated"<<endl;
    for(ctr=0;ctr<negativectr;ctr++)
    {
        cout<<negative[ctr]<<"\t";
    }

the question here is :1.) Using arrays, prompt the user to input how many random number to generate in the range of -10 to 10. Valid input is from 1-50. Display all the negative numbers entered and compute and output the sum of all the negative numbers entered. Also, display all the positive numbers entered and compute and output the product of all the positive numbers entered.

The wording in your program is a bit confusing. The user is supposed to enter a number from 1 to 50, representing the number of random numbers to be generated. However, the prompt says -10 to 10, the RANGE of the random numbers to be produced. I might run your program and enter -5, which is not valid, but I have no way of knowing that, and you give me no useful error message when I enter -5, thinking it was OK. "INVALID INPUT" is not helpful. Tell me what I did wrong so I can correct it. This holds true for the entire program. Make the wording more clear.

Line 15: This line is supposed to generate a random number from -10 to 10. Does it?
Line 18: This line is supposed to test whether the number is positive or negative. Does it?

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.