in c++ i have some code how should i pass the the struct Students to the function sortByPointTotal so that i can access that struct and edit it and sort the struct #include #include using namespace std; struct Student { string firstName, lastName; int pointTotal; }; void printStudent(const Student& s) { cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl; } void printAll(Student students[], int numStudents) { for (int i = 0; i < numStudents; i++) printStudent(students[i]); cout << endl; } sortByPointTotal() { } int main() { const int NUMSTUDENTS = 8; Student students[NUMSTUDENTS] = { {"Brian", "Jones", 45},{"Edith", "Piaf", 45}, {"Jacques", "Brel", 64},{"Anna", "Brel", 64}, {"Carmen", "Jones", 45} , {"Carmen", "Brel", 64}, {"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} }; printAll(students, NUMSTUDENTS); sortByPointTotal(students, NUMSTUDENTS); printAll(students, NUMSTUDENTS); return 0; }
in c++
i have some code how should i pass the the struct Students to the function sortByPointTotal so that i can access that struct and edit it and sort the struct
#include <string>
#include <iostream>
using namespace std;
struct Student {
string firstName, lastName;
int pointTotal;
};
void printStudent(const Student& s) {
cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl;
}
void printAll(Student students[], int numStudents) {
for (int i = 0; i < numStudents; i++)
printStudent(students[i]);
cout << endl;
}
sortByPointTotal() {
}
int main() {
const int NUMSTUDENTS = 8;
Student students[NUMSTUDENTS] = {
{"Brian", "Jones", 45},{"Edith", "Piaf", 45},
{"Jacques", "Brel", 64},{"Anna", "Brel", 64},
{"Carmen", "Jones", 45} , {"Carmen", "Brel", 64},
{"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} };
printAll(students, NUMSTUDENTS);
sortByPointTotal(students, NUMSTUDENTS);
printAll(students, NUMSTUDENTS);
return 0;
}
![1
Q#include <string>
#include <iostream>
3
4.
5
using namespace std;
7
Estruct Student {
string firstName, lastName;
int pointTotal;
[};
8.
9
10
11
12
Evoid printstudent (const Student& s) {
cout <« s.pointTotal << "\t" <« s.lastName <« ",
« s.firstName « endl;
13
14
15
Evoid printAl1(Student students[], int numStudents) {
for (int i = 0; i < numStudents; i++)
printStudent(students[i]);
cout << endl;
16
17
18
19
20
e sortByPointTotal() {
21
22
23
24
Bint main() {
25
const int NUMSTUDENTS = 8;
Student students[NUMSTUDENTS] = {
26
{"Brian", "Jones", 45},{"Edith", "Piaf", 45},
{"Jacques", "Brel", 64},{"Anna", "Brel", 64},
{"Carmen", "Jones", 45} , {"Carmen", "Brel", 64},
{"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} };
27
28
29
30
printAll(students, NUMSTUDENTS);
sortByPointTotal(students, NUMSTUDENTS);
printAll(students, NUMSTUDENTS);
31
32
33
34
35
return 0;
36
37
38
39](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffedcb44c-84a8-400b-a03e-cc7fbcfb040d%2F3b915c13-a3d6-4a33-88b6-0894ac8e657c%2F7azinzr_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









