1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <iomanip>
#include <string>
struct studentType
{
std::string studentFName;
std::string studentLName;
int testScore;
char grade;
};
int main()
{
std::cout << std::left;
studentType students[] = {
{"Nilesh", "Darji", 25, 'F'}, {"John", "Smith", 90, 'A'},
{"Michael", "Taylor", 85, 'B'}, {"Ashok", "Subramanian", 75, 'C'}};
const std::size_t maxw = 20; //I am lazy
std::cout << std::setw(maxw) << "Student name" << std::setw(11) << "Test Score" <<
std::setw(6) << "Grade\n";
for(const auto& r: students)
std::cout << std::setw(maxw) << (r.studentLName + ", " + r.studentFName) <<
std::setw(11) << r.testScore << std::setw(6) << r.grade << '\n';
}
|
Student name Test Score Grade
Darji, Nilesh 25 F
Smith, John 90 A
Taylor, Michael 85 B
Subramanian, Ashok 75 C |