Programming for Engineers Exam Review - 751 Verified Questions

Page 1


Programming for Engineers Exam

Review

Course Introduction

Programming for Engineers is designed to introduce engineering students to the fundamental concepts of computer programming and how these concepts are applied to solve engineering problems. The course covers essential programming principles such as variables, data types, control structures, functions, arrays, and object-oriented programming, typically using languages like Python, C, or MATLAB. Emphasis is placed on algorithm development, problem-solving techniques, and debugging skills through hands-on projects and assignments relevant to various engineering disciplines. By the end of the course, students will be equipped to develop, test, and implement efficient computer programs to model, analyze, and optimize real-world engineering systems.

Recommended Textbook C++ Programming From Problem Analysis to Program Design 8th Edition by D. S. Malik

Available Study Resources on Quizplus

18 Chapters

751 Verified Questions

751 Flashcards

Source URL: https://quizplus.com/study-set/3129 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/62002

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) Main memory is an ordered sequence of items, called ____.

A) pixels

B) registers

C) memory cells

D) addresses

Answer: C

Q3) A program that loads an executable program into main memory is called a(n)

A) compiler

B) loader

C) linker

D) assembler

Answer: B

Q4) ____________________ signals represent information with a sequence of 0s and 1s.

Answer: Digital digital Page 3

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

Page 4

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

Sample Questions

Q1) ____________________ is the process of planning and creating a program.

Answer: Programming programming

Q2) ____ are executable statements that inform the user what to do.

A) Variables

B) Prompt lines

C) Named constants

D) Expressions

Answer: B

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

Q4) The maximum number of significant digits in values of the double type is 15.

A)True

B)False

Answer: True

Page 5

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

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character.

A)True

B)False

Answer: True

Q2) Suppose that outFile is an ofstream variable and output is to be stored in the file outputData.out. Which of the following statements opens the file outputData.out and associates outFile to the output file?

A) outFile("outputData.out");

B) outFile.open("outputData.out");

C) open(outFile,"outputData.out");

D) open.outFile("outputData.out");

Answer: B

Q3) You can use the function getline to read a string containing blanks.

A)True

B)False

Answer: True

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

6

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

Sample Questions

Q1) For a program to use the assert function, it must include which of the following?

A) #include <assert>

B) #include <cassert>

C) #include <assertc>

D) #include NDEBUG

Q2) Which of the following operators has the lowest precedence?

A) !

B) ||

C) &&

D) =

Q3) Which of the following will cause a logical error if you are attempting to compare x to 5?

A) if (x == 5)

B) if (x = 5)

C) if (x <= 5)

D) if (x >= 5)

Q4) In C++, both ! and != are relational operators.

A)True

B)False

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

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

Sample Questions

Q1) In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.

A)True

B)False

Q2) In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).

A) looping

B) branching

C) selection

D) sequence

Q3) The control statements in the for loop include the initial statement, loop condition, and update statement.

A)True

B)False

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

Q5) The number of iterations of a counter-controlled loop is known in advance. A)True

B)False

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

Chapter 6: User-Defined Function

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2

B) 3

C) 6

D) 7

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) Given the following function prototype: Int myFunc(int, int);

Which of the following statements is valid? Assume that all variables are properly declared.

A) cin >> myFunc(y);

B) cout << myFunc(myFunc(7, 8), 15);

C) cin >> myFunc('2', '3');

D) cout << myFunc(myFunc(7), 15);

Q4) A function ____________________ is a function that is not fully coded.

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

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

Sample Questions

Q1) Which of the following is a valid C++ statement?

A) typedef integer;

B) typedef int;

C) typedef int integer;

D) typedef integer int;

Q2) The general syntax for accessing a namespace member is: namespace_name->identifier.

A)True

B)False

Q3) A data type wherein you directly specify values in the variable declaration with no type name is called a(n) ____________________type.

Q4) If a global identifier in a program has the same name as one of the global identifiers in the header file, the compiler generates a(n) ____________________ error.

Q5) In C++, you can create aliases to a previously defined data type by using the ____ statement.

A) typedef

B) using

C) namespace

D) alias

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

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The form of the for loop shown below is called a(n) ____________________ for loop.

for (dataType identifier : arrayName) statements

Q2) Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference.

A)True

B)False

Q3) A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____.

A) matrix

B) vector

C) n-dimensional array

D) parallel array

Q4) The array index can be any integer less than the array size. A)True

B)False

Q5) For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key comparisons and 3(n - 1) item assignments.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Consider the following statements: struct rectangleData { Double length; Double width; Double area; Double perimeter;

};

RectangleData bigRect; RectangleData smallRect;

Which of the following statements is legal in C++?

A) if (bigRect == smallRect)

B) if (bigRect != smallRect)

C) if (bigRect.length == width)

D) if (bigRect.length == smallRect.width)

Q2) Which of the following aggregate operations can be executed on array variables?

A) Arithmetic

B) Assignment

C) Function returning a value

D) Parameter passing by reference

Q3) Arrays are passed by ____________________ only.

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

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) If a class object is passed by ____________________, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.

Q2) The components of a class are called the ____ of the class.

A) elements

B) members

C) objects

D) properties

Q3) A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function.

A) accessor

B) mutator

C) constructor

D) destructor

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

Q5) The public members of a class must be declared before the private members. A)True

B)False

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

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) Existing classes, from which you create new classes, are called ____ classes.

A) child

B) base

C) sibling

D) derived

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) The constructors of a derived class can (directly) initialize only the (public data) members inherited from the base class of the derived class.

A)True

B)False

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

14

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

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) Which of the following arithmetic operations is allowed on pointer variables?

A) Increment

B) Modulus

C) Multiplication

D) Division

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

A) dynamic

B) new

C) virtual

D) dereferencing

Q4) The ____________________ of a base class automatically makes the destructor of a derived class virtual.

Page 15

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

Chapter 13: Overloading and Templates

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) The general syntax for the function prototype to overload the assignment operator = for a class is ____.

A) friend className& operator=(const className&);

B) className& operator=(className&);

C) string className& operator=(className&);

D) const className& operator=(const className&);

Q2) The function that overloads the ____ operator for a class must be declared as a member of the class.

A) ::

B) *

C) ->

D) +

Q3) Which of the following is the syntax to declare the operator function operator[] as a member function of a class for nonconstant arrays?

A) Type& []operator(int index);

B) Type operator[](int index);

C) Type& operator[](int index);

D) Type [](int index);

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

16

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

Q1) The class ____ is designed to deal with illegal arguments used in a function call.

A) illegal_argument

B) bad_argument

C) invalid_call

D) invalid_argument

Q2) Suppose you have written a program that inputs data from a file. If the input file does not exist when the program executes, then you should choose which option?

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.

Q3) If no exception is thrown in a try block, all catch blocks associated with that try block are ignored.

A)True

B)False

Q4) All derived classes of the class exception override the function ____________________ to issue their own error messages.

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

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

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) Consider the following code. int fact(int num)

{ if (num == 0) return 1; else return num * fact(num - 1);

} The function fact is an example of a(n) ____________________ recursive function.

Q2) Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(10) << endl;

A) 10

B) 11

C) 100

D) 110

Q3) If you execute an infinite recursive function on a computer, the function executes until the system runs out of ____________________.

Q4) The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.

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

Chapter 16: Searching and Sorting

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) If you initially declare a vector object and do not specify its size, then in order to add elements to the vector object, we use the function ____________________.

Q2) A(n) ____________________ search uses the "divide and conquer" technique to search the list.

Q3) The size of a list is fixed and cannot be increased or decreased. A)True B)False

Q4) The bubble sort makes fewer item assignments than comparisons. A)True B)False

Q5) The statement ____ returns the element at the position index in vector vecList. A) vecList[index] B) vecList.get(index)

C) vecList.front(index)

D) vecList&lt;index&gt;

Q6) The type vector provides the expression ____________________, which returns true if the object vecList is empty and false otherwise.

Q7) The first element in a vector object is at location ____________________.

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

Q8) In order to apply a(n) ____________________ search, the list must be sorted.

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

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) Consider the accompanying code. What is the effect of the following statement? newNode->info = 50;

A) Stores 50 in the info field of the newNode

B) Creates a new node

C) Places the node at location 50

D) Cannot be determined from this code

Q3) A(n) ____________________ is an object that produces each element of a container, such as a linked list, one element at a time.

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

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

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

Q2) You can perform the add operation, called ____, to add an element onto the stack.

A) pop

B) push

C) enqueue

D) dequeue

Q3) The expression a + b is the same in both infix notation and postfix notation.

A)True

B)False

Q4) The default constructor for the linked implementation of a stack initializes the stack to an empty state when a stack object is declared.

A)True

B)False

Q5) The elements at the ____________________ of the stack have been in the stack the longest.

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.