Introduction to Programming Midterm Exam - 1050 Verified Questions

Page 1


Introduction to Programming Midterm

Exam

Course Introduction

Introduction to Programming provides students with the foundational skills necessary to understand and develop basic computer programs. Through hands-on experience, students learn core programming concepts such as variables, control structures, data types, functions, and basic algorithms. The course typically uses a beginner-friendly programming language to teach problem-solving techniques, logical thinking, and debugging skills, preparing students for more advanced studies in computer science and related fields.

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 device that stores information permanently (unless the device becomes unusable or you change the information by rewriting it)is called primary storage.

A)True

B)False

Answer: False

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

A) entry

B) input

C) output

D) secondary

Answer: B

Q3) Main memory is called ____.

A) read only memory

B) random access memory

C) read and write memory

D) random read only memory

Answer: B

Q4) Word processors,spreadsheets,and games are examples of

Answer: application programs applications

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 escape sequence \r moves the insertion point to the beginning of the next line.

A)True

B)False

Answer: False

Q2) Suppose that alpha and beta are int variables.The statement alpha = --beta; is equivalent to the statement(s)____.

A) alpha = 1 - beta;

B) alpha = beta - 1;

C) beta = beta - 1;

Alpha = beta;

D) alpha = beta;

Beta = beta - 1;

Answer: C

Q3) The memory allocated for a float value is ____ bytes.

A) two

B) four

C) eight

D) sixteen

Answer: B

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

Page 4

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) Suppose that ch1,ch2,and ch3 are variables of the type char and the input is: A B C

What is the value of ch3 after the following statements execute? cin.get(ch1); cin.get(ch2); cin.get(ch3);

A) 'A'

B) 'B'

C) 'C'

D) '\n'

Answer: B

Q2) In C++,the dot is an operator called the ____________________operator. Answer: member access

Q3) C++ has a special name for the data types istream and ostream.They are called ____________________.

Answer: classes

Q4) To use a parameterized stream manipulator in a program,you must include the header file ____________________.

Answer: iomanip

Page 5

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

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) You can disable assert statements by using which of the following?

A) #include <cassert>

B) #define <assert>

C) #clear NDEBUG

D) #define NDEBUG

Q2) Once an input stream enters a(n)____________________ state,all subsequent input statements associated with that input stream are ignored,and the computer continues to execute the program,which produces erroneous results.

Q3) A(n)____________________ structure does not require the evaluation of a logical expression.

Q4) The value of the expression 7 + 8 <= 15 is ____________________.

A)True B)False

Q5) A control structure alters the normal sequential flow of execution in a program. A)True B)False

Q6) If the expression in an assert statement evaluates to true,the program terminates. A)True

B)False

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

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) To generate a random number,you can use the function rand of the header file

Q2) In a sentinel-controlled while loop,the body of the loop continues to execute until the EOF symbol is read.

A)True

B)False

Q3) When a continue statement is executed in a ____,the update statement always executes.

A) while loop

B) for loop

C) switch structure

D) do...while loop

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

Q5) The ____ statement can be used to eliminate the use of certain (flag)variables.

A) while

B) switch

C) break

D) if

Q6) The function srand takes as input a(n)____________________ int,which acts as the seed for the algorithm.

Page 7

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

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) The program that tests a function is called a(n)____________________ program.

Q2) Which of the following function prototypes is valid?

A) int funcExp(int x, float v);

B) funcExp(int x, float v){};

C) funcExp(void);

D) int funcExp(x);

Q3) The output of the statement: cout << tolower('$')<< endl; Is ____.

A) '$'

B) '0'

C) '1'

D) An error, because you cannot use tolower with '$'.

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

Q5) A variable for which memory is allocated at block entry and deallocated at block exit is called a(n)____________________ variable.

Page 8

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

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) The string expression strVar.____________________ inserts all the characters of str at index pos into strVar.

Q3) Suppose str = "ABCDEFG".The output of the statement cout << str.length()<< endl; is ____________________.

Q4) The following statement creates an anonymous type: enum {1ST,2ND,3RD,4TH} places; A)True B)False

Q5) The values in the domain of an enumeration type are called ____________________.

Q6) An anonymous type can be passed as a parameter to a function. A)True B)False

Page 9

Q7) The following is a valid C++ enumeration type: enum places {1ST,2ND,3RD,4TH};. A)True

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

Page 10

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) What is the output of the following C++ code? int list[5] = {0,5,10,15,20};

Int j;

For (j = 1; j <= 5; j++)

\(\quad\)Cout << list[j] << " ";

Cout << endl;

A) 0 5 10 15 20

B) 5 10 15 20 0

C) 5 10 15 20 20

D) Code results in index out-of-bounds

Q2) In a(n)____________________ data type,each data item is a collection of other data items.

Q3) The one place where C++ allows aggregate operations on arrays is the input and output of C-strings.

A)True

B)False

Q4) In C++,the null character is represented as ____.

A) '\0'

B) "\0"

C) '0'

D) "0"

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

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) A function can return a value of the type array.

A)True

B)False

Q2) The syntax for accessing a struct member is structVariableName____.

A) .memberName

B) *memberName

C) [memberName]

D) $memberName

Q3) A(n)____________________ is a collection of a fixed number of components in which the components are accessed by name.

Q4) You can use the assignment statement on structs.

A)True

B)False

Q5) Memory is allocated for struct variables only when you ____________________ them.

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

Q7) Consider the accompanying struct definition in Figure 1.The statement that initializes the member firstName to Melissa is ____________________.

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

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

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) A constructor with no parameters is called the ____________________ constructor.

Q2) Object code is produced from a(n)____________________.

Q3) A class object can be ____.That is,it can be created once,when the control reaches its declaration,and destroyed when the program terminates.

A) static

B) automatic

C) local

D) public

Q4) In C++ terminology,a class object is the same as a class instance.

A)True

B)False

Q5) By default,all members of a class are ____________________.

Q6) As parameters to a function,class objects can be passed by reference only. A)True

B)False

Q7) If a member of a class is ____,you cannot access it outside the class.

A) public

B) automatic

C) private

D) static

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

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) A call to the base class's constructor is specified in the heading of the definition of a derived class constructor.

A)True

B)False

Q2) Which of the following statements about inheritance is true if memberAccessSpecifier is protected?

A) The private members of the base class become protected members of the derived class.

B) The derived class can directly access any member of the base class.

C) The public members of the base class become protected members of the derived class.

D) The protected members of the base class become private members of the derived class.

Q3) ____ is the ability to use the same expression to denote different operations.

A) Inheritance

B) Encapsulation

C) Polymorphism

D) Composition

Q4) In C++,we implement ADT through the use of ____________________.

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

Page 14

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

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

Q2) In ____ binding,the necessary code to call a specific function is generated by the compiler.

A) static

B) dynamic

C) shallow

D) deep

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

A)True

B)False

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

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

Q5) The ____________________ of a list is the number of elements in the list.

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) To overload the pre-increment (++)operator for a class,if the operator function is a member of that class,it must have ____ parameter(s).

A) no

B) one

C) two

D) three

Q2) A(n)____________________ constructor converts its argument to an object of the constructor's class.

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) Most operator functions can either be member functions or nonmember functions of a class.

A)True

B)False

Q5) A conversion constructor is a(n)____________________ parameter function.

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) Suppose you have written a program that inputs data from a file.If the input file does not exist when the program executes,then which option should you choose for handling the issue?

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.

Q2) When an exception occurs in a program,the programmer usually has three choices: ____________________ the program,include code in the program to recover from the exception,or log the error and continue.

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

Q4) To deal with logical errors in a program,such as a string subscript out of range or an invalid argument to a function call,several classes are derived from the class ____.

A) logic_error

B) logic_exception

C) runtime_error

D) exception

Q5) The string concatenation operator is ____________________.

Q6) The class ____________________ contains the function what.

Page 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) Tracing through ____ recursion is more tedious than tracing other recursive forms.

A) direct

B) indirect

C) tail

D) iterative

Q2) The recursive algorithm must have one or more base cases,and the general solution must eventually be reduced to a(n)____________________.

Q3) Consider the following recursive definition,where n is a positive integer.

F(1)= 3

F(n)= F(n - 1)+ 1 if n > 1

The value of F(3)is ____________________.

Q4) 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

Q5) The ____________________ bit of 33 is 1.

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

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) The ____ deallocates the memory occupied by the nodes of a list when the class object goes out of scope.

A) constructor

B) destructor

C) head pointer

D) tail pointer

Q2) Suppose that the pointer head points to the first node in the list,and the link of the last node is NULL.The first node of the linked list contains the address of the ____ node.

A) head

B) first

C) second

D) tail

Q3) The length of a linked list is the number of nodes in the list.

A)True

B)False

Q4) The ____________________ constructor can make an identical copy of a linked list.

Q5) A linked list in which the last node points to the first node is called a(n)____________________ linked list.

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) In a queuing system,we use a(n)____________________ variable to set the status of the server.

Q2) A technique in which one system models the behavior of another system is called ____.

A) imitation

B) recursion

C) simulation

D) stimulation

Q3) The postfix expression 3 5 + 2 ; 6 - = will generate an error,because it ____.

A) contains an illegal operator

B) does not have enough operands

C) has too many operands

D) has too many operators

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

A) 4

B) 14

C) 24

D) 26

Q5) In a queuing system,every customer has a customer number,arrival time,____________________ time,transaction time,and departure time.

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 swap function of quick sort is written differently from the swap function for selection sort.

A)True

B)False

Q2) In the bubble sort algorithm,the following code accomplishes swapping values in elements at positions index and index + 1.

A) list[index] = list[index + 1]

List[index + 1] = list[index]

B) list[index + 1] = list[index]

List[index] = list[index + 1]

C) list[index] = temp;

List[index] = list[index + 1];

Temp = list[index + 1];

D) temp = list[index];

List[index] = list[index + 1];

List[index + 1] = temp;

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

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

Q5) The quick sort algorithm uses the ____________________ technique to sort a list.

Page 21

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

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

Page 22

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) In the diagram of a binary tree,an arrow is called a(n)____.

A) relation

B) path

C) directed line

D) directed branch

Q2) For classes with pointer data members,you must explicitly overload the assignment operator and include the destructor.

A)True

B)False

Q3) After inserting an item in a binary search tree,the resulting binary tree must be a(n)____________________.

Q4) The ____________________ of a binary tree is the number of nodes on the longest path from the root to a leaf.

Q5) The listing of the nodes produced by the postorder traversal of a binary tree is called the ____.

A) postsequence

B) postorder sequence

C) postorder table

D) post-script

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

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) The implementation of a breadth first graph traversal uses a stack.

A)True

B)False

Q2) A binary tree has no cycles.

A)True

B)False

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

A)True

B)False

Q4) The shortest path algorithm was developed by ____.

A) Euler

B) Kruskal

C) Prim

D) Dijkstra

Q5) The starting vertex of a shortest path in a graph is called the ____________________.

Q6) A(n)____________________ ordering of the vertices of the accompanying graph is 0,1,4,3,2,5,7,8,6,9.

Q7) A tree T is called a(n)____________________ of graph G if T is a subgraph of G such that V(T )= V(G).

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

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) Output iterators can be used to iterate over a range twice.

A)True

B)False

Q2) All containers use the same names for the common operations.

A)True

B)False

Q3) Functions begin and end do not take any parameters.

A)True

B)False

Q4) The ____ typedef iterators is common to all containers.

A) random_access

B) bidirectional

C) pointer

D) forward

Q5) An iterator to a vector container is declared using the ____ iterator.

A) new

B) vector

C) typedef

D) typeiter

Q6) ____________________ predicates check a specific property for a single argument.

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

Turn static files into dynamic content formats.

Create a flipbook