Intermediate Programming with C++ Textbook Exam Questions - 1050 Verified Questions

Page 1


Intermediate Programming with C++

Textbook Exam Questions

Course Introduction

This course builds on foundational programming knowledge to introduce students to more advanced concepts in C++. Topics covered include object-oriented programming principles such as classes, inheritance, and polymorphism, as well as exception handling, file I/O operations, and standard template library (STL) usage. Students will develop problem-solving skills by designing, implementing, and testing moderately complex applications in C++, with an emphasis on writing efficient, reusable, and maintainable code. By the end of the course, students will be equipped to tackle larger software projects and transition to advanced C++ programming.

Recommended Textbook C++ Programming Program Design Including Data Structures 6th Edition by D.S. Malik

Available Study Resources on Quizplus

21 Chapters

1050 Verified Questions

1050 Flashcards

Source URL: https://quizplus.com/study-set/319 Page 2

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/128444

Sample Questions

Q1) The ____________________ monitors the overall activity of the computer and provides services such as memory management,input/output activities,and storage management.

Answer: operating system

OS

Q2) ____________________ languages include FORTRAN,COBOL,Pascal,C,C++,and Java.

Answer: High-level

high-level

High level

high level

Q3) The devices that feed data and programs into computers are called ____ devices.

A) entry

B) input

C) output

D) secondary

Answer: B

Q4) In C++,the mechanism that allows you to combine data and operations on the data into a single unit is called a(n)____________________.

Answer: class

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Basic Elements of C++

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5305

Sample Questions

Q1) The memory space for a(n)____________________ data value is 64 bytes.

Answer: long long

Q2) The value of the expression 33/10,assuming both values are integral data types,is

A) 0.3

B) 3

C) 3.0

D) 3.3

Answer: B

Q3) In a C++ program,one and two are double variables and input values are 10.5 and 30.6.After the statement cin >> one >> two; executes,____.

A) one = 10.5, two = 10.5

B) one = 10.5, two = 30.6

C) one = 30.6, two = 30.6

D) one = 11, two = 31

Answer: B

Q4) In C++,reserved words are the same as predefined identifiers.

A)True

B)False

Answer: False

4

To view all questions and flashcards with answers, click on the resource link above.

Chapter 3: Input/Output

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5306

Sample Questions

Q1) Manipulators without parameters are part of the ____ header file.

A) iostream

B) iomanip

C) ifstream

D) pmanip

Answer: A

Q2) Suppose that x = 1565.683,y = 85.78,and z = 123.982.What is the output of the following statements?

cout << fixed << showpoint; Cout << setprecision(3)<< x << ' '; Cout << setprecision(4)<< y << ' ' << setprecision(2)<< z << endl;

A) 1565.683 85.8000 123.98

B) 1565.680 85.8000 123.98

C) 1565.683 85.7800 123.98

D) 1565.683 85.780 123.980

Answer: C

Q3) cin is called a(n)____________________ object.

Answer: istream

Q4) In C++,the dot is an operator called the ____________________operator.

Answer: member access

To view all questions and flashcards with answers, click on the resource link above. Page 5

Chapter 4: Control Structures I (Selection)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5307

Sample Questions

Q1) A compound statement functions as if it was a single statement.

A)True

B)False

Q2) For a program to use the assert function,it must include which of the following?

A) #include &lt;assert>

B) #include &lt;cassert>

C) #include &lt;assertc>

D) #include NDEBUG

Q3) In C++,both ! and != are relational operators.

A)True

B)False

Q4) In C++,&& has a higher precedence than ||.

A)True

B)False

Q5) When one control statement is located within another,it is said to be ____.

A) blocked

B) compound

C) nested

D) closed

To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Control Structures II (Repetition)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/128467

Sample Questions

Q1) Suppose sum and num are int variables,and the input is 18 25 61 6 -1.What is the output of the following code? sum = 0; Cin >> num; While (num != -1)

{

\(\quad\)Sum = sum + num; \(\quad\)Cin >> num; }

Cout << sum << endl;

A) 92

B) 109

C) 110

D) 119

Q2) In a while and for loop,the loop condition is evaluated before executing the body of the loop.Therefore,while and for loops are called ____________________ loops.

Q3) The function eof is a member of the data type ____________________.

Q4) A for loop is typically called a counted or ____________________ for loop.

Q5) The ____________________ loop has an exit condition but no entry condition.

To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: User-Defined Functions

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5309

Sample Questions

Q1) Which statement below about prototypes and headers is true?

A) Parameter names must be listed in the prototype, but not necessarily in the header.

B) Prototypes end with a semicolon, but headers do not.

C) Headers should come before prototypes.

D) Headers end with a semicolon, but prototypes do not.

Q2) If a function needs to return more than one value,as a rule of good programming style,you should change it to a(n)____________________ function and use the appropriate reference parameters to return the values.

Q3) Assume that all variables are properly declared.The following statement in a value-returning function is legal. if (x % 2 == 0)

\(\quad\)return x; else

\(\quad\)return x + 1;

A)True

B)False

Q4) Stream variables (for example,ifstream and ofstream)should be passed by ____________________ to a function.

To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7:

User-Defined Simple Data Types, Namespaces, and the string Type

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5310

Sample Questions

Q1) No arithmetic operations are allowed on the enumeration type. A)True

B)False

Q2) What is the output of the following code? enum courses {ALGEBRA,BASIC,PASCAL,PHILOSOPHY,ANALYSIS}; Courses registered; Registered = ALGEBRA;

Cout << registered << endl;

A) ALGEBRA

B) 0

C) 1

D) "ALGEBRA"

Q3) Suppose that str1,str2,and str3 are string variables.After the following statements execute,the value of str3 is "____". str1 = "abc";

Str2 = "xyz";

Str3 = str1 + '-' + str2;

A) abc

B) xyz

C) abc-xyz

D) xyz-abc

9

To view all questions and flashcards with answers, click on the resource link above.

Chapter 8: Arrays and Strings

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5311

Sample Questions

Q1) The declaration char str[] = "Hello there"; declares str to be a string of ____________________ characters.

Q2) Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int?

A) int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};

B) int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5};

C) int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5};

D) int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

Q3) What is the value of alpha[2] after the following code executes? int alpha[5]; int j; for (j = 0; j < 5; j++)

\(\quad\)alpha[j] = 2 * j + 1;

A) 1

B) 4

C) 5

D) 6

Q4) The array index can be any integer less than the array size.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Records (structs)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5312

Sample Questions

Q1) Consider the following statements: struct rectangleData

{ \(\quad\)double length; \(\quad\)double width; \(\quad\)double area; \(\quad\)double perimeter; };

rectangleData bigRect;

Which of the following statements is valid in C++?

A) cin >> bigRect;

B) cin >> bigRect.length;

C) perimeter = 2 * (length + width);

D) area = length * width;

Q2) A struct variable can be passed as a parameter ____.

A) only by const

B) only by reference

C) only by value

D) either by value or by reference

Q3) Both arrays and structs are examples of ____________________ data types.

To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Classes and Data Abstraction

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/128469

Sample Questions

Q1) Which of the following is true about classes and structs?

A) By default, all members of a struct are public and all members of a class are private.

B) A struct variable is passed by value only, and a class variable is passed by reference only.

C) An assignment operator is allowed on class variables, but not on struct variables.

D) You cannot use the member access specifier private in a struct.

Q2) In C++,the ____ is an operator called the member access operator. A) .

B) , C) :: D) #

Q3) In C++,you can pass a variable by reference and still prevent the function from changing its value by using the keyword ____ in the formal parameter declaration. A) automatic

B) private

C) static

D) const

To view all questions and flashcards with answers, click on the resource link above.

Page 12

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5314

Sample Questions

Q1) In the case of composition,the ____________________ name is used to invoke the constructor.

Q2) Consider the following class definition: class dClass: bClass { //class members list

};

The class dClass is derived from the class bClass using the ____ type of inheritance. A) public B) private C) protected D) static

Q3) In ____________________,the derived class is derived from a single base class.

Q4) The private members of a base class can be directly accessed by a derived class. A)True

B)False

Q5) If inheritance is private,all members of the base class,including private members,become private members of the derived class. A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 12: Pointers, Classes, Virtual Functions, Abstract

Classes, and Lists

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5315

Sample Questions

Q1) The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

A)True

B)False

Q2) A list is a collection of elements of the same type.

A)True

B)False

Q3) In C++,pointer variables are declared using the reserved word pointer.

A)True

B)False

Q4) Consider the following statement: ptrMemberVarType objectThree(objectOne); The values of the member variables of objectOne are being copied into the corresponding member variables of objectThree.This initialization is called the ____.

A) member-wise assignment

B) default assignment

C) member-wise initialization

D) default initialization

Q5) The binding of virtual functions occurs at program ____________________ time.

Q6) The ____________________ of a list is the number of elements in the list. Page 14

To view all questions and flashcards with answers, click on the resource link above.

Page 15

Chapter 13: Overloading and Templates

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5316

Sample Questions

Q1) Which of the following is a built-in operation on classes?

A) increment

B) assignment

C) decrement

D) relational

Q2) The associativity of the operator = is from right to left.

A)True

B)False

Q3) When the post-increment operator is overloaded as a nonmember function of the class,the operator function has ____ parameter(s).

A) no

B) one

C) two

D) three

Q4) Which of the following function prototypes overloads the != operator for the class rectangleType?

A) bool operator!=(rectangle&) const;

B) bool operator!=(const rectangleType&) const;

C) int operator!=(const rectangleType) const;

D) int operator!=(rectangle&) const;

To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5317

Sample Questions

Q1) The logic_error and runtime_error classes are defined in the header file ____.

A) stdex

B) stdlib

C) stdexcept

D) exception

Q2) Which of the following is a valid C++ statement?

A) assert(0 = divisor);

B) assert(divisor != 0);

C) assert(divisor 0);

D) assert(divisor is 0);

Q3) Which of the following options should you choose when an exception occurs in the program that analyzes an airline's ticketing transactions?

A) Terminate the program.

B) Include code in the program to recover from the exception.

C) Log the error and continue.

D) Include code in the header file.

Q4) C++ provides all the exception classes you will ever need.

A)True

B)False

Q5) The string concatenation operator is ____________________.

17

To view all questions and flashcards with answers, click on the resource link above.

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5318

Sample Questions

Q1) Consider the accompanying definition of a recursive function.Which of the statements represent the base case?

A) Statements in Lines 3 and 4

B) Statements in Lines 5 and 6

C) Statements in Lines 3-6

D) Statements in Lines 5-10

Q2) You can use a recursive algorithm to find the largest element in an array.

A)True

B)False

Q3) The ____________________ bit of 33 is 1.

Q4) The language of a computer,called ____________________ language,is a series of 0s and 1s.

Q5) A function is called ____ if it calls itself.

A) directly iterative

B) indirectly iterative

C) directly recursive

D) indirectly recursive

Q6) The numbering system that the computer uses is called the ____________________ system.

18

Q7) The collating sequence of A in the ASCII character set is

To view all questions and flashcards with answers, click on the resource link above.

Chapter 16: Linked Lists

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5319

Sample Questions

Q1) Which of the following correctly initializes a doubly linked list in the default constructor?

A) head = NULL; Back = NULL;

B) head = 0; Back = 0; Count = 0;

C) first = 0; Last = 0;

D) first = NULL;

Last = NULL; Count = 0;

Q2) Each node of a singly linked list has two components: ____ and ____.

A) info, head

B) link, back

C) back, head

D) info, link

Q3) The ____________________ operator advances the iterator to the next node in the linked list.

Q4) In a linked list,the link component of each node is a(n)____________________.

To view all questions and flashcards with answers, click on the resource link above. Page 19

Chapter 17: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5320

Sample Questions

Q1) The ____________________ constructor is called when a stack object is passed as a (value)parameter to a function.

Q2) In the linked implementation of stacks,the stack is ____________________ only if you run out of memory space.

Q3) The ____________________ elements of a stack and queue should not be accessed directly.

Q4) In the array representation of a stack,if a value called stackTop indicates the number of elements in the stack,then stackTop-1 points to the top item of the stack.

A)True

B)False

Q5) When describing a queuing system,we use the term ____________________ time to refer to the time it takes to serve a customer.

Q6) The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.

A) 4

B) 14

C) 24

D) 26

Q7) An array is a(n)____________________ access data structure.

Page 20

To view all questions and flashcards with answers, click on the resource link above.

Chapter 18: Searching and Sorting Algorithms

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5321

Sample Questions

Q1) The sequential search algorithm uses a(n)____ variable to track whether the item is found.

A) int

B) bool

C) char

D) double

Q2) A sequential search of an n-element list takes ____ key comparisons on average to determine whether the search item is in the list.

A) 0

B) n/2

C) n

D) n<sup>2</sup>

Q3) For a list of length n,selection sort makes ____ item assignments.

A) n(n - 1)/2

B) 3(n - 1)

C) 3(n)

D) 4(n + 1)

Q4) A sequence of branches in a comparison tree is called a(n)____________________.

Q5) A comparison tree is a(n)____________________ tree.

To view all questions and flashcards with answers, click on the resource link above. Page 21

Q6) The top node of a comparison tree is call the ____________________ node.

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5322

Sample Questions

Q1) Duplicates are allowed in a binary search tree.

A)True

B)False

Q2) In a binary search tree,the data in each node is ____ the data in the right child.

A) equal to

B) smaller than

C) greater than

D) smaller or equal to

Q3) A pointer to the root node of the binary tree is stored outside the binary tree in a pointer variable,usually called the ____.

A) node

B) parent

C) root

D) nodeType

Q4) Every node in a binary tree has ____ pointers.

A) one

B) two

C) three

D) four

To view all questions and flashcards with answers, click on the resource link above. Page 22

Chapter 20: Graphs

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5323

Sample Questions

Q1) We can always traverse an entire graph from a single vertex.

A)True

B)False

Q2) In a directed graph,the pairs (u,v)and (v,u)represent the same edge.

A)True

B)False

Q3) The shortest path algorithm is also called the ____ algorithm.

A) recursive

B) minimal

C) greedy

D) spanning

Q4) In a graph G,if the edges connecting two vertices have weights assigned to them,the graph is called a ____ graph.

A) source

B) weighted

C) spanning

D) minimal

Q5) A set Y is called a(n)____________________ of X if every element of Y is also an element of X.

Q6) A graph is ____________________ if the number of vertices is zero.

Page 23

To view all questions and flashcards with answers, click on the resource link above.

Chapter 21: Standard Template Library (STL)

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

Source URL: https://quizplus.com/quiz/5324

Sample Questions

Q1) If a container is declared as ____,then we must prevent the iterator from modifying the elements of the container,especially accidentally.

A) static

B) const

C) public

D) private

Q2) Every container contains the typedef ____________________.An iterator of this type is used to iterate through the elements of a container in reverse.

Q3) The deq.front()operation on a deque object checks whether the container is empty.

A)True

B)False

Q4) ____ returns the maximum number of elements that can be inserted into the vector container vecCont without reallocation.

A) vecCont.size()

B) vecCont.max_size()

C) vecCont.capacity()

D) vecCont.length()

To view all questions and flashcards with answers, click on the resource link above. Page 24

Turn static files into dynamic content formats.

Create a flipbook