Skip to main content

Introduction to C++ Programming Exam Solutions - 881 Verified Questions

Page 1


Introduction to C++ Programming Exam

Solutions

Course Introduction

Introduction to C++ Programming is a foundational course designed to equip students with essential knowledge and practical skills in computer programming using the C++ language. Through a combination of lectures and hands-on exercises, students will learn core programming concepts such as variables, data types, control structures, functions, arrays, pointers, and object-oriented programming principles like classes and inheritance. The course emphasizes problem-solving techniques, algorithm development, and the efficient use of C++ standard libraries, preparing students to design, implement, and debug simple to moderately complex programs. Upon completion, students will have a solid grounding in C++ fundamentals and be ready to tackle more advanced programming challenges.

Recommended Textbook

C++ Programming Program Design Including Data Structures 8th Edition by D. S. Malik

Available Study Resources on Quizplus 21 Chapters

881 Verified Questions

881 Flashcards

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

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Several categories of computers exist, such as ____.

A) microframe, midframe, and miniframe

B) midsize, microframe, and mainframe

C) mainsize, midsize, and microsize

D) mainframe, midsize, and micro

Answer: D

Q2) The ASCII data set consists of ____________________ characters.

Answer: 128

Q3) The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.

A) input, file, list

B) output, folder, storage

C) input, output, storage

D) storage, directory, log

Answer: C

Q4) To develop a program to solve a problem, you start by analyzing the problem.

A)True

B)False

Answer: True

Page 3

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

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/61982

Sample Questions

Q1) The smallest individual unit of a program written in any language is called a(n)

Answer: token

Q2) A data type is called ____________________ if the variable or named constant of that type can store only one value at a time.

Answer: simple

Q3) An example of a floating point data type is ____.

A) int

B) char

C) double

D) short

Answer: C

Q4) Which of the following is the newline character?

A) \r

B) \n

C) \l

D) \b

Answer: B

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

Answer: long long

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

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Suppose that ch1 and ch2 are char variables and the input is:WXYZ What is the value of ch2 after the following statements execute?

Cin >> ch1;

Ch2 = cin.peek();

Cin >> ch2;

A) W

B) X

C) Y

D) Z

Answer: B

Q2) If input failure occurs in a C++ program, the program terminates immediately and displays an error message.

A)True

B)False

Answer: False

Q3) It is a good idea to redefine cin and cout in your programs.

A)True

B)False

Answer: False

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following is the "not equal to" relational operator?

A) !

B) |

C) !=

D) &

Q2) The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.

A)True

B)False

Q3) You can use either a(n) ____ or a ____ to store the value of a logical expression.

A) float, double

B) char, string

C) int, bool

D) float, string

Q4) Which of the following is a relational operator?

A) =

B) ==

C) !

D) &&

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The statement in the body of a while loop acts as a decision maker.

A)True

B)False

Q2) Which of the following loops does not have an entry condition?

A) EOF-controlled while loop

B) sentinel-controlled while loop

C) do...while loop

D) for loop

Q3) To generate a random number, you can use the function rand of the header file ____________________.

Q4) Assume that all variables are properly declared.The following for loop executes 20 times.

for (i = 0; i <= 20; i++)

cout << i;

A)True

B)False

Q5) A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.

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

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

Chapter 6: User-Defined Function

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

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) A function prototype is ____.

A) a definition, but not a declaration

B) a declaration and a definition

C) a declaration, but not a definition

D) a comment line

Q3) A variable listed in a header is known as a(n) ____ parameter.

A) actual

B) local

C) formal

D) function

Q4) Using functions greatly enhances a program's readability because it reduces the complexity of the function main.

A)True

B)False

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

Chapter 7: Namespaces, the Class String, and

User-Defined Simple Data Types

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Before using the data type string, the program must include the header file ____.

A) enum

B) iostream

C) string

D) std

Q2) The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace ____.

A) cctype

B) stdl

C) std

D) stdlib

Q3) Consider the following statements:string str = "ABCDEFD"; string::size_type position; After the statement position = str.find('D'); executes, the value of position is ____.

A) 3

B) 4

C) 6

D) 7

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

Page 9

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Consider the following statement: int alpha[25][10];.Which of the following statements about alpha is true?

A) Rows of alpha are numbered 0...24 and columns are numbered 0...9.

B) Rows of alpha are numbered 0...24 and columns are numbered 1...10.

C) Rows of alpha are numbered 1...24 and columns are numbered 0...9.

D) Rows of alpha are numbered 1...25 and columns are numbered 1...10.

Q2) If an array index goes out of bounds, the program always terminates in an error.

A)True

B)False

Q3) Consider the following statement: double alpha[10][5];.The number of components of alpha is ____.

A) 15

B) 50

C) 100

D) 150

Q4) When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A struct is a(n) ____________________, not a declaration.

Q2) Data in a struct variable must be read one member at a time.

A)True

B)False

Q3) A struct is typically a ____ data structure.

A) simple

B) dynamic

C) heterogeneous

D) linked

Q4) In structs, you access a component by using the struct name together with the relative position of the component.

A)True

B)False

Q5) You can assign the value of one struct variable to another struct variable of ____ type.

A) a simple data

B) the same

C) an array

D) any

Q6) Arrays are passed by ____________________ only.

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

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) With ____________________ functions, the definitions of the member functions are placed in the implementations file.

Q2) 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.

Q3) Consider the UML class diagram shown in the accompanying figure.According to the UML class diagram, how many private members are in the class?

A) none

B) zero

C) two

D) three

Q4) The header file is also known as the ____________________.

Q5) A(n) ____________________ function of a class changes the values of the member variable(s) of the class.

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

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) If the derived class does not override a public member function of the base class, you may specify a call to that public member function by using the name of the function and the appropriate parameter list.

A)True

B)False

Q2) Which of the following is true about inheritance?

A) All public member functions of the base class become the public member functions of the derived class.

B) All public member variables of the base class become the public member variables of the derived class.

C) All public members of the base class become the public members of the derived class.

D) The public member variables of the base class become the public or private member variables of the derived class.

Q3) OOP implements ____.

A) UML

B) IPE

C) EIP

D) OOD

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

Page 13

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) In C++, you declare a pointer variable by using the ____ symbol.

A) *

B) & C) #

D) @

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

A)True

B)False

Q3) The C++ operator ____ is used to destroy dynamic variables.

A) destroy

B) delete

C) *

D)

Q4) The ____ constructor is executed when an object is declared and initialized by using the value of another object.

A) default

B) copy

C) struct

D) class

Page 14

Q5) A(n) ____________________ is a collection of distinct elements of the same type.

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

Page 15

Chapter 13: Operator Overloading and Templates

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) To include the operator function operator+ as a nonmember function of the class rectangleType, its prototype in the definition of rectangleType is: ____ rectangleType operator+(const rectangleType&, const rectangleType&);

A) bool

B) int

C) double

D) friend

Q2) The operators that cannot be overloaded are ., .*, ::, ?:, and ____________________.

Q3) Class templates are called ____ types.

A) polymorphic

B) structured

C) member

D) parameterized

Q4) With the exception of the ____________________ operator and the member selection operator, operators must be overloaded to be used on class objects.

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

A)True

B)False

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

43 Verified Questions

43 Flashcards

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

Sample Questions

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

A)True

B)False

Q2) In C++, throw is a(n) ____________________ word.

Q3) If the catch block with an ellipses (in the heading) is needed, then it should be the first catch block in a sequence of try/catch blocks.

A)True

B)False

Q4) Which of the following statements throws a valid exception in C++?

A) throw.function();

B) throw 2;

C) throws str;

D) 4 throw;

Q5) If you want to include members in your exception class, you typically include the function ____.

A) that

B) this

C) log

D) what

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

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

A) step-wise

B) recursive

C) member-wise

D) iterative

Q2) Consider the accompanying definition of the recursive function mystery.Given the declaration:int beta[10] = {2, 5, 8, 9, 13, 15, 18, 20, 23, 25}; What is the output of the following statement?

Cout << mystery(beta, 4, 7) << endl;

A) 27

B) 33

C) 55

D) 66

Q3) With recursion, the base case must eventually be reduced to a general case.

A)True

B)False

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

A)True

B)False

Page 18

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

40 Verified Questions

40 Flashcards

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

Sample Questions

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

A) head = nullptr; Back = nullptr;

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

C) first = 0; Last = 0;

D) first = nullptr;

Last = nullptr; Count = 0;

Q2) You can use the pointer head of a linked list to traverse the list.

A)True

B)False

Q3) For classes that include pointer data members, the assignment operator must be explicitly ____________________.

Q4) The ____________________ constructor executes when an object is declared and initialized using another object.

Q5) In C++, the dereferencing operator is ____________________.

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

Chapter 17: Stacks and Queue

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) When a stack is implemented as an array, the array is empty if the value of stackTop is ____.

A) zero

B) one

C) nonzero

D) equal to the size of the array

Q2) Postfix notation requires the use of parentheses to enforce operator precedence. A)True B)False

Q3) ____________________ techniques are used when it is too expensive or dangerous to experiment with real systems.

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

Q5) In the array representation of a stack, the stack is initialized simply by setting stackTop to ____________________.

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

Q7) In ____________________ notation, operators are written after the operands.

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

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

Chapter 18: Searching and Sorting Algorithms

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) In a quick sort, all of the sorting work is done by the function

Q2) The swap function of quick sort is written differently from the swap function for selection sort.

A)True

B)False

Q3) If n = 1000, to sort the list, bubble sort makes about ____ item assignments.

A) 10,000

B) 100,000

C) 250,000

D) 500,000

Q4) Assume that list consists of the following elements.What is the result after bubble sort completes? int list[] = {2, 56, 34, 25, 73, 46, 89, 10, 5, 16};

A) 89 73 56 46 34 25 16 10 5 2

B) 2 56 34 25 5 16 89 46 73

C) 2 5 10 16 25 34 46 56 73 89

D) 2 10 16 25 34 46 56 73 89

Q5) To construct a search algorithm of the order less than log<sub>2</sub>n, it cannot be ____________________ based.

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

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) Consider that A is a binary tree, C and D are the subtrees of A.Which of the following statements is always true?

A) C and D are binary trees.

B) C and D are search binary trees.

C) C and D are empty trees.

D) A is empty.

Q2) The key of the right child below the root node of a search binary tree is 40.The value in the root node could be ____.

A) 30

B) 40

C) 50

D) 60

Q3) When a class object is passed by value, the ____________________ constructor copies the value of the actual parameters into the formal parameters.

Q4) The level of the root node of a binary tree is 1.

A)True

B)False

Q5) The ____________________ of a path in a binary tree is the number of branches on that path.

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

Chapter 20: Graph Algorithms

Available Study Resources on Quizplus for this Chatper

48 Verified Questions

48 Flashcards

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

Sample Questions

Q1) A minimal spanning tree of G is a spanning tree with the minimum ____.

A) path

B) cycle

C) weight

D) height

Q2) A(n) ____ tree T is a simple graph such that if u and v are two vertices in T, a unique path exists from u to v.

A) rooted

B) free

C) spanning

D) weighted

Q3) The shortest path is the path with the smallest ____.

A) length

B) index

C) weight

D) key

Q4) A simple path is a path in which all vertices, except possibly the first and last vertices, are distinct.

A)True

B)False

Page 23

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

Chapter 21: Standard Template Library

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) The class ____ contains the definition of an output stream iterator.

A) iostream

B) iostream_iterator

C) ostream

D) ostream_iterator

Q2) The ____ operation returns a pointer to the position before the first element in container ct.

A) ct.front()

B) ct.rbegin()

C) ct.rend()

D) ct.end()

Q3) Random access iterators are ____ iterators that can randomly process the elements of a container.

A) bidirectional

B) forward

C) input

D) output

Q4) The associated header file of the sequence container multimap is ____________________.

Q5) List containers are implemented as doubly ____________________.

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
Introduction to C++ Programming Exam Solutions - 881 Verified Questions by Quizplus - Issuu