answersLogoWhite

0


Best Answer

Create a class to represent a student:

struct student {

string fname;

string lname;

unsigned age;

unsigned id;

};

Overload operator< to compare two student objects:

bool operator< (const student& a, const student& b) {

return a.lname<b.lname;

}

Overload std::ostream::operator<< to print a student:

std::ostream& operator<< (std::ostream& os, const student& s) {

return os << s.fname << ' ' << s.lname << ' ' << s.age << ' ' << s.id;

}

Now you can write your program:

int main() {

std::vector<student> v;

for (unsigned count=0; count<100;) {

student s;

std::cout << "Enter details for student #" << ++count;

std::cout << "First name: ";

std::cin >> s.fname; std::cout << "Last name: ";

std::cin >> s.lname;

std::cout << "Age: ";

std::cin >> s.age;

std::cout << "ID: ";

std::cin >> s.id;

v.push_back (s);

}

std::cout << "Sorting..."

std::sort (v.begin(), v.end());

std::cout << "\n\n";

// Print students...

for (auto s : v) std::cout << s << std::endl;

}

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the C plus plus program to display fname lname age and id number of 100 students and arrange their name alphabetically?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you start the display program in Linux from the command line?

the command "display" brings up the ImageMagick program.


What college can arrange for me to Study Abroad in France?

There are a very large amount of schools that can arrange for you to study abroad in France. The University of Minnesota, Morris is an excellent public liberal arts college that has an international exchange program. American InterContinental University will arrange everything for a student to study abroad in France. Arcadia offers great study abroad programs with tons of help for students that are interested.


When was Victorian Students' Aid Program created?

Victorian Students' Aid Program was created in 2005.


How do you get a Java program to display a backslash in output without it interpreting it as a program command?

Follow the backslash with another backslash: System.out.println("\\ " \"); will display \ " \ on the screen.


Why do people like the pathways program at John Abbott College it is such a bad program?

It's a bad program for good students, it's a good program for evil students


Program that interprets and display webpages?

browser


What is the name of the application that lets you arrange musical notes and play it?

A notation program.


7 of the 20 students attend an after school art program what percent of the students attend the program?

7 divided by 20


What grants are available for startup program for tutuoring students after school?

what grants are available for startup program for tutoring students after school?


What is an extended minor program?

Typically, it is a program that is embedded into a students primary program of study (major), and is taking because of an interest within another field, or because it will enhance a students primary program of study.


Draw a flowchart that will accept radius and display the area of circle?

program that display the area of a circle of a reduce


What will be the program to arrange numbers stored in array in ascending order using pointers?

sorry