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";
}