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

in a code like structure example: In order to use your structure to hold data on

ID: 3778747 • Letter: I

Question

in a code like structure example:

In order to use your structure to hold data on a particular student, you must declare a variable of type StudentRecord. (How you deal with the set of these records that represent a class of students is covered when we discuss arrays.)

We can proceed to initialize the members of record1 by using dot-notation:

We can now use this initialized structure in other programmatic statements:

Design a structure to represent a student's transcript; you do not have to include all the data is the student's master record. What members would you include and what are each of the members' types?

Explanation / Answer

#include <iostream>
using namespace std;

struct StudentRecord //structure for student
{
   string firstName;
   string lastName;
   string studentID;
   float courseAverage;
};

int main()
{
   struct StudentRecord record1; //structure variable
  
       record1.firstName = "John"; //initialize structure variable members
record1.lastName = "Jones";
record1.studentID = "S0123456789";
record1.courseAverage = 89.6;
  
cout << "Student Record for: " << record1.firstName <<' ' << record1.lastName << " ID: " <<record1.studentID << " Average: " << record1.courseAverage << endl;
  
   return 0;
}

output:

structure members and their types

string firstName;
   string lastName;
   string studentID;
   float courseAverage;