Discrete Mathematics and Programming Test Questions - 766 Verified Questions

Page 1


Discrete Mathematics and Programming Test Questions

Course Introduction

This course provides a foundational understanding of discrete mathematics concepts essential to computer science and programming. Students will explore topics such as logic, set theory, relations and functions, combinatorics, graph theory, and algorithms, emphasizing their applications in developing computational solutions. The course bridges mathematical theory with practical programming, guiding students in translating mathematical reasoning into code using modern programming languages. By the end of the course, students will have developed analytical problem-solving skills and the ability to implement algorithms that efficiently solve discrete problems commonly encountered in computing.

Recommended Textbook

Starting out with C++ Early Objects 9th Edition by Tony Gaddis

Available Study Resources on Quizplus

19 Chapters

766 Verified Questions

766 Flashcards

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

Page 2

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The computer's main memory is commonly known as

A) direct-access memory (DAM).

B) random-access memory (RAM).

C) read only memory (ROM).

D) secondary storage.

E) none of the above.

Answer: B

Q2) The ________ coordinates the computer's operations by fetching the next instruction and using control signals to regulate the other major computer components.

A) arithmetic and logic unit (ALU)

B) traffic controller

C) instruction manager

D) control unit

E) operating system

Answer: D

Q3) Most modern computers can understand and execute pseudocode.

A)True

B)False

Answer: False

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

Page 3

Chapter 2: Introduction to C Plus Plus

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) What value will be assigned to the variable number by the following statement?

Int number = 7.8;

A) 7

B) 8

C) 7.8

D) None of the above.

E) It's unpredictable. That's the problem.

Answer: A

Q2) Every C++ program must have

A) comments.

B) variables.

C) literals.

D) a function called main..

E) all of the above.

Answer: D

Q3) C++ is a case-sensitive language.

A)True

B)False

Answer: True

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The following C++ statement will assign 1.5 to the result variable. int result = 3.0 / 2.0;

A)True

B)False

Answer: False

Q2) When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

A) values, exponents

B) operators, calculations

C) operators, operands

D) operators, parentheses

E) operands, parentheses

Answer: D

Q3) The following two expressions evaluate to the same thing:

c + a * b

c + (a * b)

A)True

B)False

Answer: True

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) To check if a variable has a particular value, use the = relational operator, as in the statement if (s = 3)

cout << "S has the value 3";

A)True

B)False

Q2) The ________ operator is known as the logical OR operator. A) !

B) & C) && D) ||

E) //

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

A)True

B)False

Q4) All of the relational operators are binary.

A)True

B)False

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

Chapter 5: Looping

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) What will the following code print?

Num = 8;

Cout << --num << " ";

Cout << num++ << " ";

Cout << num;

A) 7 7 8

B) 7 8 8

C) 8 7 7

D) 8 7 8

E) None of these

Q2) To use files in a C++ program you must include the ________ header file.

A) fstream

B) iostream

C) file

D) Both A and B are needed.

E) Both B and C are needed.

Q3) When a loop is nested inside another loop, the inner loop goes through all its iterations for each iteration of the outer loop.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.

A)True

B)False

Q2) When used as a parameter, a ________ variable allows a function to access and modify the original argument passed to it.

A) static

B) value

C) reference

D) floating-point

E) default value

Q3) A function with a return type of bool must return a value of either True or false.

A)True

B)False

Q4) A function can have zero to many parameters and either zero or one return value(s). A)True B)False

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

8

Chapter 7: Introduction to Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A constructor may have a return type of

A) int

B) bool

C) void

D) any of the above.

E) none of the above.

Q2) The ________ is used to protect important data.

A) default constructor

B) class protection operator

C) protect() member function

D) public access specifier

E) private access specifier

Q3) When an object or structure variable is passed to a function as a constant reference

A) the function accesses the original object, rather than a copy of it.

B) the function cannot make any changes to the member variables.

C) it is more efficient than passing it by value.

D) all of the above are True.

E) A and B are True, but not C.

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

9

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The range-based for loop may be used with arrays, but not with vectors.

A)True

B)False

Q2) Which of the following statements correctly initialize the value variable?

A) int value = 8;

B) int value{8};

C) int value(8);

D) All of the above.

E) Both A and B, but not C.

Q3) After carrying out the following two statements, sales will have been created as a one-dimensional array that can hold 20 double values. typedef salesArray double[20]; salesArray sales;

A)True

B)False

Q4) The size of an array is the number of elements that have data stored in them. A)True

B)False

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

Chapter 9: Searching, Sorting, Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A sorting algorithm can be used to arrange a set of ________ in ________ order. A) numeric values, ascending B) numeric values, descending C) strings, ascending D) strings, descending E) All of the above.

Q2) To find a value in an ordered array of 50 items, how many values must binary search examine at most.

A) 1

B) 6

C) 10

D) 25

E) 50

Q3) When searching for an item in an unordered set of data, binary search can find the item more quickly than linear search.

A)True

B)False

Q4) A binary search requires that the elements be in order.

A)True

B)False

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

Chapter 10: Pointers

Available Study Resources on Quizplus for this Chatper

62 Verified Questions

62 Flashcards

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

Sample Questions

Q1) With pointer variables you can access, but you cannot modify, data in other variables.

A)True

B)False

Q2) When the less than ( < ) operator is used between two pointer variables, the expression is testing whether

A) the value pointed to by the first is less than the value pointed to by the second.

B) the value pointed to by the first is greater than the value pointed to by the second.

C) the address of the first variable comes before the address of the second variable in the computer's memory.

D) the first variable was declared before the second variable.

E) None of the above

Q3) You may use the type pointer to a structure as the type of a

A) function parameter.

B) structure member.

C) function return type.

D) All of the above

E) None of the above

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

12

Chapter 11: More About Classes and Object-Oriented Programming

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) The this pointer is automatically passed to static member functions of a class. A)True

B)False

Q2) When you redefine the way a standard operator works when it is used with class objects, you have ________ the operator.

A) reassigned

B) reformatted

C) overloaded

D) overwhelmed

E) None of the above

Q3) In the statement class Car:protected Vehicle, what is being protected?

A) Derived class functions

B) Base class members

C) Derived class data

D) Future inherited classes

E) None of the above

Q4) A base class cannot contain a pointer to one of its derived classes. A)True

B)False

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

Chapter 12: More on C-Strings and the String Class

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) To access the last character of a string class object str you can use the expression

A) str[last].

B) str.last().

C) str[str.length()].

D) str[str.length()-1].

E) None of the above

Q2) The string class append member function str.append(s)tacks a string s to the end of str.

A)True

B)False

Q3) A good way to convert a value of type double to a string is

A) use the ostringstream class.

B) use the strtodouble function.

C) use the doubletoa function.

D) use the doublestringstream class.

E) None of the above

Q4) A C-string can be assigned to a variable whose type is the string class.

A)True

B)False

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

Chapter 13: Advanced File and Io Operations

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The process of writing in-memory objects to a file so that the object can later be read back into memory

A) requires the use of specialized convert constructors.

B) is called serialization.

C) requires special operation system support.

D) is called deserialization.

E) None of the above

Q2) File output may be formatted the same way as screen output.

A)True

B)False

Q3) The term ________ means non-sequentially accessing information in a file.

A) cin.getline

B) cin.getrandom

C) random access

D) read.randomly

E) None of the above

Q4) The read and write member functions of fstream objects can only work with buffers specified by pointers to char.

A)True

B)False

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

Chapter 14: Recursion

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) The quicksort algorithm can be used to

A) sort lists stored in arrays.

B) perform binary search on arrays.

C) quickly sort and search arrays.

D) All of the above

E) None of the above

Q2) The QuickSort algorithm was developed in 1960 by

A) Bjarne Stroustrup.

B) Tony Gaddis.

C) C.A.R. Hoare.

D) Judy Walters.

E) None of the above

Q3) The base case of a recursive function

A) is 0.

B) is 1.

C) is depth / 2.

D) is 1 / (depth * 3.1415).

E) depends on the problem being solved.

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

Chapter 15: Polymorphism and Virtual Functions

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) Declaring a member function of a class to be a ________ will cause the C++ compiler to use dynamic binding.

A) constructor function

B) destructor function

C) static function

D) virtual function

E) None of the above

Q2) In C++ polymorphism is very difficult to achieve unless you also use inheritance.

A)True

B)False

Q3) When a virtual member function of a class in a class hierarchy is invoked through a pointer to an object in the class hierarchy, the compiler will select the member function to be invoked

A) from the class of the type of the pointer.

B) from the class of the object that is pointed to.

C) from the base class of the inheritance hierarchy.

D) from the derived class of the base pointer object.

E) None of the above

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

Chapter 16: Exceptions, Templates, and the Standard

Template Library Stl

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A ________ is a "generic" function that can work with different data types.

A) function argument

B) function parameter

C) function template

D) member function

E) None of the above

Q2) Class templates allow you to create one general version of a class without having to A) write any code.

B) use member functions.

C) use private members.

D) duplicate code to handle multiple data types.

E) None of the above

Q3) The beginning of a function template is marked by a A) return type.

B) parameter list.

C) template prefix.

D) semicolon.

E) None of the above

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) If a node is not the first node in a linked list, deleting it may require setting the successor pointer in its predecessor.

A)True

B)False

Q2) When you delete a node from a linked list, you must ensure that the links in the surrounding nodes are set to bypass the node being deleted.

A)True

B)False

Q3) The Standard Template Library (STL) provides a linked list container.

L) provides a linked list container.

A)True

B)False

Q4) To build a linked list, we can

A) start with an empty list, and then form an array of nodes.

B) start with an empty list, and then perform a series of add item operations.

C) use the constructor to create an array of nodes.

D) call the list init function.

E) None of the above

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

19

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) In a dequeue operation, the element at the ________ of the queue is removed.

A) middle

B) front

C) declaration

D) mid-point

E) None of the above

Q2) A(n) ________ is an abstract data type that stores and retrieves items in a last-in-first-out manner.

A) array

B) queue

C) stack

D) vector

E) None of the above

Q3) The STL provides containers for deque and queue.

A)True

B)False

Q4) A dynamic stack starts as an empty linked list.

A)True

B)False

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

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

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

Sample Questions

Q1) Binary tree are called "trees" because they resemble an upside-down tree.

A)True

B)False

Q2) Visiting all nodes of a binary tree in some methodical fashion is known as A) climbing the tree.

B) traversing the tree.

C) walking through tree.

D) branching out along the tree.

E) None of the above

Q3) If a node has no successor, the corresponding pointer is set to A) the root of the tree.

B) point to its parent node.

C) a leaf.

D) NULL .

E) None of the above

Q4) Deleting a leaf node from a binary search tree is not difficult. Deleting a non-leaf node requires several steps.

A)True

B)False

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

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
Discrete Mathematics and Programming Test Questions - 766 Verified Questions by Quizplus - Issuu