Ok, I also need to calculate and display each height after a 5% increase using a separate 10-element array. Any ideas? Sorry about all this. This is my first time using arrays.
#include <iostream>
using namespace std;
int main()
{
int MINheight = 0;
double height[10];
for (int x = 0; x < 10; x = x + 1)
{
height[x] = 0.0;
}
cout << "You are asked to enter heights of 10 students. "<< endl;
for (int x = 0; x < 10; x = x + 1)
{
cout << "Enter height of a student: ";
cin >> height[x];
}
system("pause");
return 0;
}
std::min_elementis right on your doorstep.std::beginandstd::end, which works with plain arrays, as well as the betterstd::array.std::transformexists. In standard C++03, the best you're probably going to get is something likestd::bind2nd(std::multiplies<double>, 1.05)for the transformation (can't say I've ever had to use that, so I don't know if it's completely right), but C++11 gives us nice lambdas:[](double d){return d * 1.05;}. Again, something to keep in the back of your mind as you learn the language.