9 PDF

Title 9
Author Chung cxchen
Course Problem Solving & Prgmng I Lab
Institution Old Dominion University
Pages 4
File Size 137.5 KB
File Type PDF
Total Downloads 14
Total Views 177

Summary

chapter 9...


Description

Test 9

1.

2.

3.

4.

5.

6.

In C++, the ________ is an operator called the member access operator. a. dot (.) b. semicolon (;) c. exclamation point (!) d. underscore (_)  Which of the following statements is FALSE? a. You cannot assign a struct variable to another of a different type. b. To compare the values of struct variables, you must compare them member-wise. c. You can use relational operators on struct variables. d. You can use an assignment statement to copy the contents of one struct variable into another of the same type.  The members of a struct are enclosed in ________ . a. {} b. () c. d. []  Which of the following aggregate operations is NOT permitted on structs or arrays? a. passing to a function b. assignment c. arithmetic d. returning from a function  Given a struct variable named student and a member variable GPA of type double, which of the following statements initializes GPA to 0.0? a. GPA.student = 0.0; b. student(GPA) = 0.0; c. student.GPA = 0.0; d. student.GPA(0.0);  Given a struct variable named student and a member variable GPA of type double, how would you read a value into GPA? a. cin >> student.GPA; b. cin >> GPA; c. cin >> student(GPA); d. cin >> student >> GPA; 

7.

8.

9.

10.

11.

12.

13.

Which of the following statements is TRUE? a. Data in struct variables must be read one member at a time. b. Data in struct variables cannot be input or output. c. Aggregate input operations are allowed on struct variables. d. Aggregate output operations are allows on struct variables.  Which of the following statements is TRUE regarding the relationship between structs and functions? a. A function can only return a reference to a struct. b. A function can return a value of type struct. c. A function cannot return a value of type struct. d. A function cannot return an individual member of a struct.  Which of the following statements is TRUE? a. A function cannot return a value of type struct. b. A function can return a value of type struct. c. A struct variable can only be passed by value. d. A struct variable can only be passed by reference.  The only built-in operations on a struct are the ________ and member access operations. a. concatenation b. assignment c. addition d. logic  A struct is a ________ data type. a. parameterized b. simple c. primitive d. structured  The members of a struct statement are separated by ________ . a. braces ({}) b. colons (:) c. commas (,) d. semicolons (;)  Suppose you have a struct type named employeeType. You have declared an array named employees with 50 elements of type employeeType. The employeeType struct has a member variable called firstName. What is the syntax for accessing the value of firstName in the first element of employees? a. employees.firstName[0] b. employees[0].firstName

14.

15.

16.

17.

18.

19.

20.

c. firstName[0] d. employees.firstName(0)  Which of the following statements declares a variable named student of the struct type studentType? a. struct student(studentType); b. studentType student; c. studentType[student]; d. studentType(student);  Which of the following statements is TRUE of struct variable declarations? a. Only one variable of a struct may be declared within a program. b. Struct variables must be declared globally. c. Struct variables can only be declared in main. d. Struct variables can be declared as part of the struct definition.  Which of the following statements is TRUE? a. A struct can have only one component. b. Components of a struct can be of different types. c. Components of a struct must be of different types. d. Components of a struct must be of the same type.  The syntax for accessing a struct member is ________ . a. structVariableName >> memberName b. structVariableName(memberName) c. structVariableName.memberName d. structVariableName[memberName]  Suppose you have two struct variables of the same type named student and newStudent. What is the result of the statement student = newStudent? a. The memory location of student is copied into newStudent. b. The memory location of newStudent is copied into student. c. The contents of newStudent are copied into student. d. The contents of student are copied into newStudent.  The components of a struct are called ________ . a. elements b. types c. indices d. members  A struct may ________ . a. contain multiple structs of the same type

b. contain more than one struct, but not of the same type c. not be declared within more than one struct. d. not contain more than one struct ...


Similar Free PDFs