Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a complete C++ program called hw14.cpp defines a struct called person as f

ID: 3625773 • Letter: W

Question

Write a complete C++ program called hw14.cpp defines a struct called person as follows

struct person
{ string first;
string last;
int age;
};

Your program should prompt the user for a value for each field. It should then store the user’s input in such a struct. It should then print out the student’s name and age.

SAMPLE RUN
Please enter your first name: Jane
Please enter your last name: Doe
Please enter your age: 19


Hi Jane Doe! You are 19 years old.

NOTE: Recall that you can read a string in directly using cin, you DON’T have to read it in char by char

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
struct person
{ string first;
string last;
int age;
};
int main ()
{person p;
cout<<"Please enter your first name: ";
cin>>p.first;
cout<<"Please enter your last name: ";
cin>>p.last;
cout<<"Please enter your age: ";
cin>>p.age;
cout<<"Hi "<<p.first<<" "<<p.last<<"! You are "<<p.age<<" years old"<<endl;
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote