Given the declaration of the Name type in Exercise 12 and th
Solution
Given structure of studentRecord is as follows
struct studentRecord
{
Name studentName;
Name teacherName;
int gradeNumber;
string grades;
}
studentRecord sally;
a) Setting the name Sally Ellen Strong to studentName in sttudentRecord
sally.Name=\"Sally Ellen Strong\";
b)Setting the grade number 7 to the grade of sally
sally.gradeNumber=7;
c)Setting fourth letter of grades field
sally.grades[3]=spring[3];
Since index of the string starts from 0.
Given Name structure
struct Name
{
string first;
string middle;
string last;
};
Name yourName;
Name myName;
a.yourName.first=\"George\"
yourName
first=\"George\"
middle =null;
last=null;
myName=null;
b)
yourName.last=\"Smith\"
yourName
first=\"George\"
middle =null;
last=\"Smith\";
myName=null;
c)
myName=yourName;
yourName
first=\"George\"
middle =null;
last=\"Smith\";
myName
myName.first=\"George\"
myName.middle =null;
myName.last=\"Smith\";
d)
myName.middle=\"Nathaniel\";
myName
myName.first=\"George\"
myName.middle =\"Nathaniel\";
myName.last=\"Smith\";
e)
yourName.middle=myname.middle.at(0)+\".\";
yourName
middle=\"N.\"
The middle string index value is replaced with first letter of the middle string
and \'.\'

