#include <iostream>
Don't use plagiarized sources. Get Your Custom Essay on
(Solved Homework): Create a student struct that has the following fields: First name Last name . Age ·ID Here are the instructions e Ask the user how many students is in his/her class….
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
#include <string>
#include <iomanip>
using namespace std;
struct student
{
string FirstName;
string LastName;
int age;
int ID;
};
void getdata(student *st, int size) //getdata function to get inputs from user
{
for(int i=0 ; i<size; i++)
{
cout << “nStudent #” << (i+1) << endl;
cout << “—————————-” << endl;
cout << “Enter Student’s first name : “;
cin >> st[i].FirstName;
cout << “Enter Student’s last name : “;
cin >> st[i].LastName;
cout << “Enter age : “;
cin >> st[i].age;
cout << “Enter Student ID : “;
cin >> st[i].ID;
cin.ignore();
}
}
void displaydata(student *st, int size) //displaydata functioin is to print student details
{
cout << “nStudent Details:”;
for(int i=0 ; i<size; i++)
{
cout << “nStudent #” << (i+1) << endl;
cout << “—————————-” << endl;
cout << “First Name : ” << st[i].FirstName << endl;
cout << “Last Name : ” << st[i].LastName << endl;
cout << “Age : ” << st[i].age << endl;
cout << “ID : ” << st[i].ID << endl;
}
}
int main()
{
int size;
cout << “How many Students? “;
cin >> size;
student *st = new student[size]();
getdata(st, size); //calling getdata function by passing student array and size as parameters
displaydata(st, size); //calling displaydata function by passing student array and size as parameters
return 0;
}