SYCS-135� Introduction to Programming

 

Quiz 10 - 11/22/99

 

 

 

Name:� ___Solutions____________________________��������������������������� ID:� __________________��������������������� �����������������������������������������������

�

 

1.[2] Write the C++ statement that would declare a data type that is comprised of� 21

�characters.� The name of the used defined type should be nametype.

 

_____typedef�� char__nametype[22]_____________________________________________

 

 

�2. [4]� Write the C++ statement that would declare a structured data type named

student_record.� This heterogeneous collection of component should have a variable called std_NAME of the type you defined in the first problem.� Also, it must have the following components:�

�����������

����������� float student_GPA;

����������� char std_ID [6];

����������� char std_GRADE;

�

����������� ____struct___ student_record___________________________________________

����������� ____{_____________________________________________________________

����������� __________nametype _std_NAME______� _______________________________

����������� __________float__student_GPA;________________________________________

����������� __________char__std_ID[6];___________________________________________

����������� __________char__std_GRADE; ������_____________________________________

����������� ____}_____________________________________________________________

 

 

3. [4] Write the C++ statements that would declare a variable of the type defined in problem 2.� Name this variable my_record.� Next, assign your last name to the component called std_NAME.� Also, assign 3.45 to the student_GPA component, assign �009999� to the std_ID component� and assign �A� to the� std_GRADE component.

 

���� ________student_record ____my_record; _________________________________

����������� ________my_record.std_NAME =�keeling�;_______________________________

����������� ________my_record.std_GPA = 3.45;____________________________________

����������� __my_record.std_ID = �00999�;___________________________________

_��� _____my_record.std_GRADE = �A�;__________________________________

__________________________________________________________________

__________________________________________________________________