C.S. 150 Chapter 7 (User-Defined Simple Data Types, Namespaces, and the stringType)

Ace your homework & exams now with Quizwiz!

Before using the data type string, the program must include the header file ____. A. enum B. iostream C. string D. std

C. string

Which of the following is a valid C++ statement? A. typedef integer; B. typedef int; C. typedef int integer; D. typedef nteger int;

C. typedef int integer;

Suppose str= "xyzw";. After the statement str[2] = 'Y'; The value of stris "____". A. xyzw B. xYzw C. xyYw D. xzYw

C. xyYw

Which of the following statements creates an anonymous type? A. enumgrades {A, B, C, D, F}; B. enumgrades {}; C. enum {}; D. enum {A, B, C, D, F} grades;

D. enum {A, B, C, D, F} grades;

Which of the following statements declares the studentGrade variable? A. enumstudentGrade{A, B, C, D, F}; B. enumint{A, B, C, D, F} studentGrade; C. enumstudentGrade{A, B, C, D, F} grades; D. enumgrades {A, B, C, D, F} studentGrade;

D. enumgrades {A, B, C, D, F} studentGrade;

A function cannot return the value of an enumeration type. True or False?

False

An enumeration type can be passed as a parameter to a function only by value. True or False?

False

typedef statement

used to create synonyms or aliases to a data type

Anonymous type

values are directly specified in the declaration, with no type name

string str= "ABCDEFD"; After the statement position = str.find('D'); executes, the value of position is ____. A. 3 B. 4 C. 6 D. 7

A. 3

What is the output of the following code? enumcourses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS}; courses registered; registered = ALGEBRA; cout<< registered << endl; A. ALGEBRA B. 0 C. BASIC D. PASCAL

B. 0

enum cars {FORD, GM, TOYOTA, HONDA}; cars domesticCars= FORD; The statement: domesticCars=static_cast<cars>(domesticCars+ 1); sets the value of domesticCarsto ____. A. FORD B. GM C. TOYOTA D. HONDA

B. GM

string str1 = "Gone with the wind"; string str2; After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____". A. Gone B. with C. the D. wind

B. with

Suppose str= "ABCDEFGHI". The output of the statement cout<< str.length() << endl; is ____. A. 7 B. 8 C. 9 D. 10

C. 9

The following is a legal C++ enumeration type enum colorType {BLUE, GREEN, 2PINK, YELLOW, RED}; True or False?

False

No arithmetic operations are allowed on the enumeration type. True or False?

True

Data type

a set of values with a set of operations on them

Enumeration type

a simple data type created by the programmer

An enumeration type is an _____________________.

ordered set of values


Related study sets

A+ 3.1 Install and configure laptop hardware and components

View Set

Gateway B2+ English-German Unit 7

View Set

Functional Area 5: Total Rewards

View Set

Sociology 1103 Exam 1 Study Guide

View Set

Marketing Lecture Slides (Chapters 14 - 20)

View Set

Intro to Sociology Chapter 6 quiz

View Set