#include <iostream>
#include <string>
struct Person {
std::string name;
int age;
float height;
};
int main() {
// Declare an array of Person structures
Person people[3];
// Assign values to the members of the first Person structure
people[0].name = "John Smith";
people[0].age = 30;
people[0].height = 1.75;
// Assign values to the members of the second Person structure
people[1].name = "Jane Smith";
people[1].age = 25;
people[1].height = 1.65;
// Assign values to the members of the third Person structure
people[2].name = "Bob Smith";
people[2].age = 35;
people[2].height = 1.80;
// Print the values of the members of the Person structures
for (int i = 0; i < 3; i++) {
std::cout << "Name: " << people[i].name << std::endl;
std::cout << "Age: " << people[i].age << std::endl;
std::cout << "Height: " << people[i].height << std::endl;
}
return 0;
}

0 Comments