Logic Flashcards
Question: What are the three classes of constructs required to complete a programming language according to the given text?
Answer: The three classes of constructs required to complete a programming language are sequential constructs, selection constructs, and iteration constructs.
Question: Why is it important for software to be readable and easy to upgrade and maintain?
Answer: It is important for software to be readable and easy to upgrade and maintain because programmers who maintain application software are typically not those who develop the software originally, and the maintenance programmers may change throughout the lifetime of a software application.
Question: What are the principles of structured programming, and when were they developed?
Answer: The principles of structured programming were developed in the 1960s and provide important coding guidelines that respect the objective of making software readable, easy to upgrade, and maintainable. A structured program consists of sets of simple constructs, each of which has one entry point and one exit point. Any programmer may replace one construct with an upgraded construct without affecting the other constructs in the program or introducing errors (“bugs”).
Question: What is a code block, and how is it different from a single statement in C programming?
Answer: A code block is a set of statements enclosed in a pair of curly braces to be executed sequentially. Unlike a single statement, a C code block does not require a terminating semi-colon of its own (after the closing brace).
Question: What does the chapter describe about implementing structured programming principles in coding iterations?
Answer: The chapter introduces the selection and iteration constructs supported by the C language and describes how to implement structured programming principles in coding iterations.
Question: What are some techniques used during the design stage of a programming solution?
Answer: Some well-established techniques include pseudo-coding and flow charting.
Question: What is pseudo-code?
Answer: Pseudo-code is a set of shorthand notes in a human (non-programming) language that itemizes the key steps in the sequence of instructions that produce a programming solution.
Question: What is flow charting?
Answer: Flow charting is a set of conventional symbols connected by arrows that illustrate the flow of control through a programming solution.
Question: What are the three selection constructs supported by the C language?
Answer: The three selection constructs supported by the C language are the optional path, alternative paths, and conditional expression.
Question: What is the binary selection construct?
Answer: The binary selection construct executes one of a set of alternative sequences and takes the form if (condition) sequence else sequence.
Question: What is the suggested coding style for maximum readability and maintainability?
Answer: It is suggested to create a code block for single-line statements, including the placement of the opening and closing curly braces on their own dedicated lines.
Question: What is the syntax for a multiple selection construct in C programming?
Answer: The syntax for a multiple selection construct in C programming is:
if (condition1)
sequence1
else if (condition2)
sequence2
else
sequence3
Question: What is the syntax for a case-by-case selection construct in C programming?
Answer: The syntax for a case-by-case selection construct in C programming is:
switch (condition)
{
case constant1:
sequence1
break;
case constant2:
sequence2
break;
default:
sequence3
}
Question: What is the purpose of the conditional expression selection construct in C programming?
Answer: The purpose of the conditional expression selection construct in C programming is to provide shorthand for the alternative path construct, which allows for a more concise syntax for conditional statements.
Question: What are the three iteration constructs supported by the C language?
Answer: The three iteration constructs supported by the C language are while, do while, and for.