Skip to main content

C++ Programming Practice Questions - 949 Verified Questions

Page 1


C++ Programming Practice Questions

Course Introduction

C++ Programming is an introductory course designed to familiarize students with the fundamental concepts and techniques of programming using the C++ language. The course covers essential topics such as variables, data types, control structures, functions, arrays, pointers, and object-oriented programming principles, including classes and inheritance. Emphasis is placed on problem-solving skills, algorithm development, and practical application of programming concepts through a series of hands-on coding exercises and projects. By the end of the course, students will be able to design, implement, test, and debug basic to moderately complex C++ programs.

Recommended Textbook

Starting Out with C++ from Control Structures to Objects 9th Edition by Tony Gaddis

Available Study Resources on Quizplus

21 Chapters

949 Verified Questions

949 Flashcards

Source URL: https://quizplus.com/study-set/1368

2

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) What does the term hardware refer to?

A) The relative difficulty of writing computer programs

B) The physical components that make up a computer

C) The way a computer's storage space is organized

D) The logical flow of instructions

E) None of these

Answer: B

Q2) The term "bit" stands for binary digit.

A)True

B)False

Answer: True

Q3) This is a complete instruction that causes the computer to perform some action:

A) line

B) statement

C) variable

D) key word

E) None of these

Answer: B

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

3

Chapter 2: Introduction to C

Available Study Resources on Quizplus for this Chatper

62 Verified Questions

62 Flashcards

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

Sample Questions

Q1) The preprocessor executes after the compiler.

A)True

B)False

Answer: False

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

A) April2018

B) employee_number

C) _1user

D) 1user

E) theLittleBrownFoxWhoRanAway

Answer: D

Q3) What is the value of number after the following statements execute?

Int number; Number = 18 / 4;

A) 4.5

B) 4

C) 2

D) 0

E) unknown Answer: B

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

Chapter 3: Expressions and Interactivity

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) The fixed manipulator causes a number to be displayed in scientific notation.

A)True

B)False

Answer: False

Q2) When C++ is working with an operator, it strives to convert the operands to the same type.

A)True

B)False

Answer: True

Q3) When a program uses the setw manipulator, the iosetwidth header file must be included in a preprocessor directive.

A)True

B)False

Answer: False

Q4) Arithmetic operators that share the same precedence have right to left associativity.

A)True

B)False

Answer: False

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

Chapter 4: Making Decisions

Available Study Resources on Quizplus for this Chatper

51 Verified Questions

51 Flashcards

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

Sample Questions

Q1) These operators connect two or more relational expressions into one, or reverse the logic of an expression.

A) relational

B) logical

C) irrational

D) negation

E) None of these

Q2) If the expression on the left side of the following is False, the expression on the right side will not be checked. (a > = b) && (c == d)

A)True

B)False

Q3) The following code correctly determines whether x contains a value in the range of 0 through 100, inclusive. if (x > 0 && <= 100)

A)True

B)False

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

Chapter 5: Loops and Files

Available Study Resources on Quizplus for this Chatper

60 Verified Questions

60 Flashcards

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

Sample Questions

Q1) What will the following code display?

Int number = 6;

Int x = 0;

X = number--;

Cout << x << endl;

A) 6

B) 5

C) 7

D) 0

Q2) The while loop is a __________ loop.

A) post-test

B) pre-test

C) infinite

D) limited

E) None of these

Q3) You may nest while and do-while loops but you may not nest for loops.

A)True

B)False

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

Chapter 6: Functions

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) When used as parameters, these types of variables allow a function to access the parameter's original argument:

A) reference

B) floating-point

C) counter

D) undeclared

E) None of these

Q2) A _________ variable is declared outside all functions.

A) local

B) global

C) floating-point

D) counter

E) None of these

Q3) __________ functions may have the same name as long as their parameter lists are different.

A) Only two

B) Two or more

C) No

D) Un-prototyped

E) None of these

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

Chapter 7: Arrays and Vectors

Available Study Resources on Quizplus for this Chatper

56 Verified Questions

56 Flashcards

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

Sample Questions

Q1) An individual array element can be processed like any other type of C++ variable.

A)True

B)False

Q2) The range-based for loop in C++11 is designed to work with a built-in variable known as

A) the counter

B) the i variable

C) an iterator

D) the range variable

E) None of these

Q3) This vector function returns true if the vector has no elements.

A) has_no_elements

B) null_size

C) empty

D) is_empty

Q4) If you attempt to store data past an array's boundaries, it is guaranteed to cause a compiler error.

A)True

B)False

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

Chapter 8: Searching and Sorting Arrays

Available Study Resources on Quizplus for this Chatper

30 Verified Questions

30 Flashcards

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

Sample Questions

Q1) Regardless of the algorithm being used, a search through an array is always performed

A) from lowest to highest element

B) from highest to lowest element

C) beginning with the middle element

D) using a binary search algorithm

E) None of these

Q2) A __________ search is more efficient than a __________ search.

A) character, string

B) integer, double

C) binary, linear

D) linear, binary

E) None of these

Q3) The __________ is adequate for searching through small arrays.

A) binary search

B) the linear search

C) unary search

D) bubble sort

E) None of these

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

Page 10

Chapter 9: Pointers

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) A function may return a pointer but the programmer must ensure that the pointer

A) still points to a valid object after the function ends

B) has not been assigned an address

C) was received as a parameter by the function

D) has not previously been returned by another function

E) None of these

Q2) Which of the following statements is not valid C++ code?

A) int ptr = &num1;

B) int ptr = int *num1;

C) float num1 = &ptr2;

D) All of these are valid

E) All of these are invalid

Q3) In the following statement, what does int mean?

Int *ptr = nullptr;

A) The variable named *ptr will store an integer value.

B) The variable named *ptr will store an asterisk and an integer value

C) ptr is a pointer variable and will store the address of an integer variable.

D) The variable named *ptr will store the value in nullptr.

E) None of these

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

Page 11

Chapter 10: Characters, C-Strings, and More About the String Class

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) The expression being tested by the statement shown below will evaluate to true if var1 is __________. if (!isdigit(var1))

A) an alphabetic character

B) 9

C) a symbol such as $ or &

D) both A and C

E) None of these

Q2) To determine whether a character entered is whitespace, use the __________ function.

A) iswhite

B) isspace

C) iswhitespace

D) isblank

E) None of these

Q3) The C++ library provides functions for converting a string representation of a number to a numeric data type and vice-versa.

A)True

B)False

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

Chapter 11: Structured Data

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) Which of the following assigns a value to the hourlyWage member of employee[2]?

A) employee[2] -> hourlyWage = 50.00;

B) employee2.hourlyWage = 7.50;

C) hourlyWage[2].employee = 29.75;

D) employee[2].hourlyWage = 75.00;

E) None of these

Q2) A structure pointer contains

A) the address of a structure variable

B) the dereferenced address of a structure tag

C) the name and address of the structure tag

D) the address of a structure tag

E) None of these

Q3) Which of the following is an example of a C++ primitive data type?

A) unsigned short int

B) long double

C) unsigned char

D) All of these

E) None of these

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

13

Chapter 12: Advanced File Operations

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Which of the following access flags, when used by itself, causes a file's contents to be deleted if the file already exists?

A) ios::app

B) ios::in

C) ios::out

D) Any of these

E) None of these

Q2) Which of the following statements opens a file and links it to a file stream object?

A) open(aFile) = link(anObject);

B) file.open("filename.txt");

C) linkstream("filename.txt");

D) link(open("filename.txt");

E) None of these

Q3) All stream objects have __________ which indicate the position of the stream.

A) error state bits

B) condition statements

C) markers

D) intrinsic error messages

E) None of these

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

Page 14

Chapter 13: Introduction to Classes

Available Study Resources on Quizplus for this Chatper

54 Verified Questions

54 Flashcards

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

Sample Questions

Q1) When a constructor function accepts no arguments, or does not have to accept arguments because of default arguments, it is called a(n)

A) empty constructor

B) default constructor

C) stand-alone function

D) arbitrator function

E) None of these

Q2) You must use the private access specification for all data members of a class.

A)True

B)False

Q3) In OOP terminology, an object's member variables are often called its __________ and its member functions can be referred to as its behaviors or its __________.

A) values, morals

B) data, activities

C) attributes, activities

D) attributes, methods

E) None of these

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

15

Chapter 14: More About Classes

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) You can overload the conditional operator to make it function as an unconditional operator.

A)True

B)False

Q2) A non-static member function may not access a static member variable.

A)True

B)False

Q3) When you overload the << operator you must also overload the >> operator.

A)True

B)False

Q4) In C++11 reference variables that can refer only to temporary objects that would otherwise have no name are called __________ and are declared with a

A) rvalues, ampersand (&)

B) lvalues, ampersand (&)

C) lvalues, double ampersand (&&)

D) rvalues, double ampersand (&&)

E) None of these

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

Chapter 15: Inheritance, Polymorphism, and Virtual Functions

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) Functions that are dynamically bound by the compiler are __________ functions.

A) constructor

B) destructor

C) static

D) virtual

E) None of these

Q2) A __________ of a base class expects to be overridden in a derived class.

A) constructor function

B) destructor function

C) static function

D) virtual function

E) None of these

Q3) Arguments are passed to the base class destructor by the __________ class __________ function.

A) derived, constructor

B) derived, destructor

C) base, constructor

D) base, destructor

E) None of these

Page 17

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

Chapter 16: Exceptions and Templates

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) Using a function template requires less code than overloading a function.

A)True

B)False

Q2) The __________ starts with the key word try and is followed by a block of code that executes any statement that might cause an exception to be thrown..

A) try block

B) try/catch class

C) try function

D) catch function

E) None of these

Q3) Which of the following is used to signal errors or unexpected results that happen as a program runs?

A) virtual functions

B) destructors

C) exceptions

D) templates

E) None of these

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

Chapter 17: The Standard Template Library

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Two types of container classes in the STL are

A) sequence and associative

B) box and cylinder

C) array and struct

D) constant and literal

E) None of these

Q2) To use the binary_search() algorithm you need to include ___________

A) two arguments which are iterators

B) two header files, algorithm.h and search.h

C) three arguments which are two iterators and a value

D) one argument which is a value

E) None of these

Q3) An associative container stores data in a nonsequential way so it is slower to locate elements than a sequence container.

A)True

B)False

Q4) An iterator is a function that is used to access items in an array.

A)True

B)False

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

Chapter 18: Linked Lists

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) Which type of list does not contain a null pointer at the end of the list?

A) backwards linked

B) doubly linked

C) circular linked

D) null linked

E) None of these

Q2) The process of moving through a linked list is referred to as __________ the list.

A) cruising

B) traversing

C) hopping

D) revising

E) None of these

Q3) When you delete a node from a list, you must ensure that the links in the list are not permanently broken.

A)True

B)False

Q4) If there are no nodes in a linked list, you cannot append a node to the list.

A)True

B)False

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

Chapter 19: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) Given the following code, assume the myStack object is a stack that can hold integers and that value is an int variable. 1 myStack.push(0);

2 myStack.push(1);

3 myStack.push(2);

4 myStack.pop(value);

5 cout << value << endl;

Assume that the pop function, called on line 4, stores the number popped from the stack in the value variable. What will the statement on line 5 display?

A) 0

B) 1

C) 2

D) None of these

Q2) In a dequeue operation, the element at the __________ of the queue is removed. A) middle

B) front

C) declaration

D) rear

E) None of these

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

Chapter 20: Recursion

Available Study Resources on Quizplus for this Chatper

27 Verified Questions

27 Flashcards

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

Sample Questions

Q1) A __________ function is one that calls itself.

A) dynamic

B) static

C) validation

D) recursive

E) None of these

Q2) Any algorithm that can be coded with recursion can also be coded with an iterative structure.

A)True

B)False

Q3) When recursion is used on a linked list, it will always display the contents of the list in reverse order.

A)True

B)False

Q4) If a recursive algorithm does not contain a base case, it

A) returns 0 and stops

B) returns False and stops

C) uses up all available stack memory, causing the program to crash

D) reaches the recursive case and stops

E) None of these

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

Chapter 21: Binary Trees

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

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

Sample Questions

Q1) In a binary tree, each node must have a minimum of two children.

A)True

B)False

Q2) The InOrder, PreOrder, and PostOrder traversals can be accomplished using A) recursion

B) no pointers

C) no arguments

D) no parameters

E) None of these

Q3) The shape of a binary tree is

A) always triangular

B) always balanced

C) determined by the programmer

D) determined by the order in which values are inserted

E) None of these

Q4) The PostOrder method of traversing a binary tree involves processing the node's data, traversing the node's right subtree, and then traversing the node's left subtree.

A)True

B)False

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

Turn static files into dynamic content formats.

Create a flipbook
C++ Programming Practice Questions - 949 Verified Questions by Quizplus - Issuu