Programming Fundamentals Midterm Exam - 1050 Verified Questions

Page 1


Programming Fundamentals

Midterm Exam

Course Introduction

Programming Fundamentals introduces students to the basic concepts of computer programming and problem-solving using a structured, high-level programming language. The course covers essential topics such as variables, data types, operators, control structures, functions, arrays, and debugging techniques. Emphasis is placed on developing logical thinking and algorithmic approaches to solve computational problems. Through hands-on exercises and projects, students will gain practical experience in writing, testing, and maintaining simple programs, building a solid foundation for advanced study in computer science and related disciplines.

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 devices that feed data and programs into computers are called output devices.

A)True

B)False

Answer: False

Q2) The ASCII data set consists of ____________________ characters.

Answer: 128

Q3) The programming language C++ evolved from ____.

A) BASIC

B) assembly

C) C

D) C+

Answer: C

Q4) A(n)____ consists of data and the operations on those data.

A) disk

B) compiler

C) interpreter

D) object

Answer: D

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

Sample Questions

Q1) ____________________ functions are those that have already been written and are provided as part of the system.

Answer: Predefined predefined Standard standard

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) A(n)____________________ is a collection of statements,and when it is activated,or executed,it accomplishes something. Answer: subprogram sub program sub-program function modlue

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) In the statement cin >> x;,x can be a variable or an expression.

A)True

B)False Answer: False

Q2) The following statements will result in input failure if the input values are not on a separate line.(Assume that x and y are int variables.) cin >> x; cin >> y;

A)True

B)False Answer: False

Q3) Entering a char value into an int variable causes serious errors,called input failure.

A)True

B)False Answer: True

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

Answer: classes

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) The value of the expression 7 + 8 <= 15 is ____________________.

A)True

B)False

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) The expression (x >= 0 && x <= 100)evaluates to false if either x < 0 or x >= 100.

A)True

B)False

Q4) To output results correctly,the switch structure must include a(n)____________________ statement after each cout statement,except the last cout statement.

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

Q6) Putting ____________________ in front of a logical expression reverses the value of that logical expression.

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) What is the next Fibonacci number in the following sequence? 1,1,2,3,5,8,13,21,...

A) 34

B) 43

C) 56

D) 273

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

A) while B) switch

C) break

D) if

Q3) What is the output of the following C++ code? num = 10; while (num > 10)

\(\quad\)num = num - 2;

cout << num << endl;

A) 0

B) 6

C) 8

D) 10

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

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Given the following function prototype: int test(float,char);,which of the following statements is valid?

A) cout << test(12, &);

B) cout << test("12.0", '&');

C) int u = test(5.0, '*');

D) cout << test('12', '&');

Q2) In C++,a function prototype is the function heading without the body of the function.

A)True

B)False

Q3) A(n)____________________ parameter is a formal parameter that receives the location (memory address)of the corresponding actual parameter.

Q4) Functions that do not have a return type are called ____ functions.

A) zero

B) null

C) void

D) empty

Q5) If a formal parameter is a nonconstant reference parameter,during a function call,its corresponding actual parameter must be a(n)____________________.

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) The following statement creates an anonymous type: enum {1ST,2ND,3RD,4TH} places;

A)True

B)False

Q2) A function cannot return the value of an enumeration type.

A)True

B)False

Q3) Suppose str = "xyzw";.After the statement str[2] = 'Y'; The value of str is "____".

A) xyzw

B) xYzw

C) xyYw

D) xzYw

Q4) Which of the following statements is used to simplify the accessing of all globalType namespace members?

A) using globalType;

B) using namespace globalType:all;

C) using namespace globalType::all;

D) using namespace globalType;

Q5) The length of the string "Hello There." is ____________________.

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

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) In the following declaration,the array gamma has ____________________ components.

int gamma[5][6][10];

Q2) In a two-dimensional array,the elements are arranged in a table form. A)True B)False

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 header file string contains the function ____________________,which converts a value of type string to a null-terminated character array.

Q5) The following statements store the value ____________________ into len. int len; len = strlen("Sunny California");

Page 10

Q6) The statement strlen("Marylin Stewart"); returns ____________________.

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

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) Aggregate input/output operations are allowed on a struct variable.

A)True

B)False

Q2) A function can return a value of the type struct.

A)True

B)False

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

Q4) To compare struct variables,you compare them ____.

A) by reference

B) by value

C) index-wise

D) member-wise

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

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

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

Q8) A(n)____________________ is a set of elements of the same type.

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

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

A)True B)False

Q3) A(n)____________________ statement is required by any program that uses a header class file,as well as by the implementation file that defines the operations for that class.

Q4) Consider the accompanying class definition,and the object declaration: rectangleType bigRect(14,10);

Which of the following statements is correct?

A) bigRect.setLengthWidth();

B) bigRect.setLengthWidth(3.0, 2.0);

C) bigRect.length = 2.0;

D) bigRect.length = bigRect.width;

Q5) Non-static member variables of a class are called the ____________________ variables of the class.

Q6) In C++,class is a reserved word and it defines only a data type.

A)True

B)False

Page 12

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

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

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

Q2) The preprocessor directive ____________________ is used to prevent multiple inclusions of a header file in a program.

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

A)True

B)False

Q4) The private members of a base class can be directly accessed by a 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) In ____ binding,the necessary code to call a specific function is generated by the compiler.

A) static

B) dynamic

C) shallow

D) deep

Q2) The statement that declares board to be a pointer to a pointer is: int ____________________;

Q3) A pointer variable is a variable whose content is a memory address.

A)True

B)False

Q4) The C++ operator ____ is used to create dynamic variables.

A) dynamic

B) new

C) virtual

D) dereferencing

Q5) A memory leak is an unused memory space that cannot be allocated.

A)True

B)False

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) The ____________________ operator function as a member of a class has only one parameter; as a nonmember of a class,it has two parameters.

Q2) Suppose cType is a class template,and func is a member function of cType.The heading of the function definition of func is: ____.

A) template &lt;class Type&gt; FuncType cType&lt;Type&gt; == func(parameters)

B) template &lt;class Type&gt; FuncType cType&lt;Type&gt; C) template &lt;class Type&gt; FuncType cType&lt;Type&gt;::func(parameters)

D) template &lt;class Type&gt; FuncType cType&lt;Type&gt;func(parameters);

Q3) The declaration of a friend function cannot be placed within the private part of the class.

A)True B)False

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

Q5) The ____________________ operator causes a member-wise copy of the member variables of the class.

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) In C++,throw is a(n)____________________ word.

Q2) The class ____ is the base of the classes designed to handle exceptions. A) class

B) exception

C) logic_error

D) runtime_error

Q3) The try block is followed by one or more ____ blocks. A) throw

B) finally C) do D) catch

Q4) If the operator new cannot allocate memory space,this operator throws a(n)____________________ exception.

Q5) C++ provides all the exception classes you will ever need. A)True B)False

Q6) The string concatenation operator is ____________________.

Q7) The class ____________________ contains the function what.

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

Q8) A(n)____________________ block specifies the type of exception it can catch and contains an exception handler.

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) A function is called ____ if it calls itself.

A) directly iterative

B) indirectly iterative

C) directly recursive

D) indirectly recursive

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

Q3) The fourth Fibonacci number in a sequence is the sum of the ____________________ Fibonacci numbers.

Q4) The collating sequence of A in the ASCII character set is ____________________.

Q5) In the Tower of Hanoi recursive program,if needle 1 contains three disks,then the number of moves required to move all three disks from needle 1 to needle 3 is 8. A)True

B)False

Q6) 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) A(n)____________________ is an object that produces each element of a container,such as a linked list,one element at a time.

Q2) Consider the accompanying statements.The list is empty if the pointer first is ____.

A) NULL

B) 0

C) last

D) next

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

Q4) Every node (except of the last node)in a singly linked list contains ____.

A) the next node

B) no address information

C) the address of the next node

D) the address of the previous node

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

A) info, head

B) link, back

C) back, head

D) info, link

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 the late 1950s,the Australian philosopher and early computer scientist Charles L.Hamblin proposed a scheme in which the operators follow the operands (postfix operators),resulting in the ____________________ notation.

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

Q3) To describe a queuing system,we use the term ____ for the object receiving the service.

A) client

B) server

C) customer

D) provider

Q4) If you try to add a new item to a full stack,the resulting condition is called an outflow. A)True

B)False

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

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

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

Q2) With the binary search algorithm,____ key comparison(s)is/are made in the successful case-the last time through the loop.

A) one

B) two

C) n-2

D) n

Q3) For a list of length n,insertion sort makes ____ key comparisons,in the worst case.

A) n(n - 1)/4

B) n(n - 1)/2

C) n<sup>2</sup>

D) n<sup>3</sup>

Q4) Any sorting algorithm that sorts a list of n distinct elements by comparison of the keys only,in its worst case,makes at least ____________________ key comparisons.

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

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 C++,a function name without any parentheses is considered a pointer to the function.

A)True

B)False

Q2) In a(n)____________________ traversal,the binary tree is traversed as follows:

1. Visit the node.

2.Traverse the left subtree.

3.Traverse the right subtree.

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

Q4) Let T be a binary search tree with n nodes,in which n > 0.When T is linear,the search algorithm makes ____________________ key comparisons,in the unsuccessful case.

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

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) A minimal spanning tree of G is a spanning tree with the minimum ____.

A) path

B) cycle

C) weight

D) height

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

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

Q4) In a graph directed G,for each vertex,v,the vertices adjacent to v are called ____ successors.

A) immediate

B) adjacent

C) path

D) parallel

Q5) The two most common graph traversal algorithms are depth first traversal and breadth first traversal.

A)True

B)False

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) The operator ____________________,supported by the queue container class,returns the next (i.e.,first)element in the queue,but does not remove the element from the queue.

Q2) The expression ct.____________________ deletes all of the elements from the container ct.

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

A) random_access

B) bidirectional

C) pointer

D) forward

Q4) In the ____ sort algorithm,the array containing the data is viewed as a binary tree.

A) modifying

B) heap

C) nonmodifying

D) numeric

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

A)True

B)False

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 24

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.