Docsity

Solutions For Programming Logic and Design.pdf, Exams of Nursing

Toggle sidebar
bg1
Solutions For Programming Logic and Design, 10th Edition Farrell (All Chapters
included).
Chapter 1: An Overview of Computers and Programming
1. Computer programs also are known as ____________.
a) Data
b) Hardware
c) Software
d) Processors
Answer: c
Rationale: Software refers to the programs that instruct the computer what to do,
as opposed to hardware, which is the physical equipment.
2. The major computer operations include ____________.
a) Input, processing, and output
b) Hardware and software
c) Sequence and looping
d) ASCII and EBCDIC
Answer: a
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Solutions For Programming Logic and Design.pdf and more Exams Nursing in PDF only on Docsity!

Solutions For Programming Logic and Design, 10th Edition Farrell (All Chapters included). Chapter 1: An Overview of Computers and Programming

  1. Computer programs also are known as ____________. a) Data b) Hardware c) Software d) Processors Answer: c Rationale: Software refers to the programs that instruct the computer what to do, as opposed to hardware, which is the physical equipment.
  2. The major computer operations include ____________. a) Input, processing, and output b) Hardware and software c) Sequence and looping d) ASCII and EBCDIC Answer: a

Rationale: All computer programs fundamentally perform three operations: they accept input, process that input according to instructions, and produce output.

  1. Visual Basic, C++, and Java are all examples of computer ____________. a) Operating systems b) Programming languages c) Hardware d) Machine languages Answer: b Rationale: These are high-level programming languages used by developers to write instructions that are later translated into machine language.
  2. A programming language's rules are its ____________. a) Syntax b) Logic c) Format d) Options Answer: a Rationale: Syntax is the specific set of grammatical rules that must be followed to write valid code in a particular language.
  1. Which of the following pairs of steps in the programming process is in the correct order? a) Code the program, plan the logic b) Test the program, translate it into machine language c) Put the program into production, understand the problem d) Code the program, translate it into machine language Answer: d Rationale: After planning and coding the logic, the source code must be translated (compiled/interpreted) into machine language before it can be executed.
  2. A programmer's most important task before planning the logic of a program is to ____________. a) Decide which programming language to use b) Code the problem c) Train the users of the program d) Understand the problem Answer: d Rationale: Understanding the requirements is the prerequisite to any successful programming. You cannot design a solution without fully understanding the problem.
  1. The two most commonly used tools for planning a program's logic are ____________. a) ASCII and EBCDIC b) Java and Visual Basic c) Flowcharts and pseudocode d) Word processors and spreadsheets Answer: c Rationale: Flowcharts provide a visual representation of program flow, while pseudocode describes the logic in plain English. Both are language-independent.
  2. Writing a program in a language such as C++ or Java is known as _______ the program. a) Translating b) Coding c) Interpreting d) Compiling Answer: b Rationale: The act of writing the source code in a specific programming language is referred to as coding.
  1. In a flowchart, a rectangle represents ____________. a) Input/Output b) A sentinel c) A question d) Processing Answer: d Rationale: Rectangles, or "process" boxes, represent calculations, data manipulations, or assignments.
  2. In flowcharts, the decision symbol is a ____________. a) Parallelogram b) Rectangle c) Lozenge d) Diamond Answer: d Rationale: Diamonds represent decision points where the program evaluates a condition (true/false) and branches accordingly.
  3. The term "eof" represents ____________. a) A standard input device

b) A generic sentinel value c) A condition where no more memory is available d) End of file Answer: d Rationale: EOF is a marker or condition indicating that no more data can be read from a file.

  1. When you use an IDE instead of a simple text editor to develop a program, ____________. a) The logic is more complicated b) The logic is simpler c) The syntax is different d) Some help is provided (syntax highlighting, debugging) Answer: d Rationale: Integrated Development Environments (IDEs) provide tools like code completion, debugging, and syntax highlighting to assist the programmer.
  2. As compared to procedural programming, with object-oriented programming, ____________. a) The programmer's focus differs

d) It requires an interpreter to run. Answer: c Rationale: Machine language is the binary representation of instructions that the CPU executes directly.

  1. What is the purpose of a "sentinel" value in a program? a) To perform arithmetic operations b) To indicate the end of data entry c) To start the program d) To store the final output Answer: b Rationale: A sentinel (or dummy value) is used in loops to signal that there is no more input to process, allowing the loop to terminate. Chapter 2: Elements of High-Quality Programs
  2. Which of the following is a valid variable name in most languages? a) 3rdPlace b) hourly-rate c) total_Score d) while

Answer: c Rationale: Variable names typically cannot start with numbers, contain hyphens (use underscores), or use reserved keywords like 'while'.

  1. Which data type would be most appropriate to store a person's age? a) String b) Character c) Integer d) Float Answer: c Rationale: Age is a whole number (typically) with no decimal component, making an integer the most efficient choice.
  2. What does the "=" symbol represent in most programming languages? a) Equality comparison b) Assignment c) Initialization d) Declaration Answer: b

Rationale: Constants are similar to variables but are immutable. Attempting to change them usually results in an error. They improve code safety.

  1. Uninitialized variables cause ____________. a) Syntax errors b) Logical errors or unpredictable results c) Compiler optimization d) Faster execution Answer: b Rationale: If a variable holds random data (garbage) before assignment, using it in calculations leads to unpredictable output (a logic error).
  2. When you perform division on two integers in languages like Java or C++, if the result is not an integer, the result is ____________. a) Rounded up b) Converted to a float automatically c) Truncated (chopped off) d) Stored as a character Answer: c

Rationale: This is called integer division. The fractional part is discarded (e.g., 5 / 2 = 2).

  1. The modulus operator (%) returns ____________. a) The quotient of division b) The remainder of division c) The product of two numbers d) The absolute value Answer: b Rationale: Modulus is useful for checking divisibility (e.g., number % 2 gives 0 for even numbers).
  2. Which of the following is a valid assignment statement? a) 5 = x + y b) x + y = 5 c) x = x + 1 d) x == y Answer: c Rationale: The right side is evaluated, and the result is stored in the left side (variable). x = x + 1 increments x by 1.
  1. Which of the following is NOT a common integral data type? a) int b) float c) short d) long Answer: b Rationale: Float is a floating-point (decimal) data type. Int, short, and long are integral types.
  2. The process of breaking a large program into smaller, manageable pieces is known as ____________. a) Modularization b) Compilation c) Iteration d) Sequencing Answer: a Rationale: Modularization (using functions or methods) improves readability, reusability, and manageability of code.
  3. Which of the following is a benefit of using named constants?

a) They use less memory than variables. b) The program runs faster. c) The code becomes self-documenting and easier to maintain. d) It eliminates the need for data types. Answer: c Rationale: If a value like PI is used many times, a constant makes the code readable and allows you to change the value in one place if needed.

  1. What is a "string" in programming? a) A single character b) A sequence of characters c) An integer with a decimal d) A Boolean value Answer: b Rationale: A string is a data type used to represent text, such as "Hello World".
  2. Which is an example of integer division resulting in a loss of data? a) 10.0 / 2. b) 10 / 2

Answer: a Rationale: Concatenation (usually the + operator) joins strings together. Often the number 42 would be implicitly converted to a string.

  1. Why is program maintenance often the most expensive phase of the software lifecycle? a) It requires the most expensive hardware. b) It happens frequently over many years to fix bugs or add features. c) It is the only phase that requires a compiler. d) It must be done by the original programmer. Answer: b Rationale: Maintenance covers everything done after the software is deployed, including bug fixes, updates, and new features, often for 5-10+ years.
  2. Which key word is commonly used to declare a constant in many languages? a) var b) dynamic c) const or final d) let Answer: c

Rationale: const (C++, JavaScript) and final (Java) are modifiers that indicate a variable's value cannot be reassigned after initialization. Chapter 3: Understanding Structure

  1. Snarled, tangled, or poorly organized program logic is often called ____________ logic. a) Spaghetti b) Ravioli c) Pizza d) Lasagna Answer: a Rationale: "Spaghetti code" refers to logic with many unstructured jumps (like GOTOs), making it difficult to follow.
  2. The three fundamental control structures of structured programming are ____________. a) Input, Process, Output b) Sequence, Selection, and Loop c) Variable, Constant, Literal d) Syntax, Logic, Debugging