It will give us a better idea if you could post your current code here or are you just asking for suggestions on this?
zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
You could do that through dynamic allocation or setting maximums.
thines01
Postaholic
2,424 posts since Oct 2009
Reputation Points: 445
Solved Threads: 402
Set a maximum of 100 people. I'm sure that's more than anyone simply testing your program will enter, and if they try to enter 101 a simple error message will prevent it.
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Not exactly sure if my code is perfect (coding on the fly, here) but I believe this should work.
#include <iostream>
using namespace std;
int main()
{
int max, height, shoeSize; weight, avgHeight, avgShoe, avgWeight;
int sumHeight = 0, sumShoe = 0, sumWeight = 0;
cout << "Please enter in the number of people you would like to enter data for: ";
cin >> max;
for(int i = 1; i <= max; i++)
{
cout << "Please enter in person " << i << "'s height: ";
cin >> height;
sumHeight += height;
cout << "Please enter in person " << i << "'s shoe size: ";
cin >> shoeSize;
sumShoe += shoeSize;
cout << "Please enter in person " << i << "'s weight: ";
cin >> weight;
sumWeight += weight;
}
avgHeight = sumHeight/max;
avgShoe = sumShoe/max;
avgWeight = sumWeight/max;
cout << endl;
cout << "The average height is: " << avgHeight << endl;
cout << "The average shoe size is: " << avgShoe << endl;
cout << "The average weight is: " << avgWeight << endl << endl;
return 0;
}
yongj
Junior Poster in Training
79 posts since May 2010
Reputation Points: 11
Solved Threads: 1