how can I use a loop to sum random numbers together? it needs to be able to sum any amount of numbers determined by the user. I can generate the random numbers but adding them is a different story. I tried to make an inner loop (if that makes sense) but all that does is display the sum of each number. Effectively displaying the random number again and not adding anything. Then I tried to add the calculation in the loop and got a similar thing. I just need to add the numbers up at the end.
int main()
{
int randValue;
int a,b,i,n,sum, entry, y, count;
char again = 'y';
double average;
while (again == 'y')
{
cout << " enter the number of random numbers (1-100): "<<endl;
cin >> n;
cout << endl;
if (n <= 100)
{srand(time(NULL)); // seed
cout << "Please enter the range you want (lowest to highest) : " <<endl;
{
count = 5
for (i = 1; i <= n; i++)
{
randValue = a + rand() % (b+1-a);
cout << randValue << " ";
if(i%count==0) cout<<endl;
sum=0;
sum = sum+randValue;
cout << "sum = " <<sum <<endl;
cout << endl;
}
return 0;}
}} }