C Write a program that will take in the names of a group of
C++ Write a program that will take in the names of a group of people(up to 100), along with their heights in feet and inches rounded to the nearest inch.
The program should then say who is Tallestn and Shortest.
You must do this using only a Single Array. You will need a class or a structure for this.
NO FANCY CODES PLEASE
Solution
#include <iostream>
using namespace std;
class People {
std::string name;
double height;
public:
void setName(string name) {
this->name = name;
}
void setHeight(double height) {
this->height = height;
}
double getHeight() {
return height;
}
std::string getName() {
return name;
}
};
int main() {
// your code goes here
People people[100];
string name;
double height;
int tallest = 0;
int smallest = 0;
for(int i=0;i<100;i++) {
cout<<\"\ Enter name\";
cin>>name;
cout<<\"\ Enter height\";
cin>>height;
people[i].setName(name);
people[i].setHeight(height);
if(people[tallest].getHeight() < height) {
tallest = i;
}
if(people[smallest].getHeight() > height) {
smallest = i;
}
}
cout<<\"\ The tallest person is \"<<people[tallest].getName();
cout<<\"\ The smallest person is \"<<people[smallest].getName();
return 0;
}

