asked 137k views
4 votes
Create a simple structure program in c++​

1 Answer

3 votes
Here's a simple structure program in C++:

```
#include
using namespace std;

struct person {
string name;
int age;
double height;
};

int main() {
person p;

cout << "Enter name: ";
cin >> p.name;
cout << "Enter age: ";
cin >> p.age;
cout << "Enter height: ";
cin >> p.height;

cout << "Name: " << p.name << endl;
cout << "Age: " << p.age << endl;
cout << "Height: " << p.height << endl;

return 0;
}
```

This program creates a `person` struct that contains a `name`, `age`, and `height`. It then prompts the user to enter values for these fields and prints them out.
answered
User Tony Edgecombe
by
8.6k points

No related questions found