1.
A programmer will use __________ to decide whether the set of instructions is to be executed based on the condition whether it is TRUE or FALSE.
Correct Answer
B. Decision logic structure
Explanation
A programmer will use the decision logic structure to decide whether the set of instructions is to be executed based on the condition whether it is TRUE or FALSE. This structure allows the programmer to control the flow of the program by evaluating a condition and executing different blocks of code based on the result. It is commonly used in programming languages to implement if-else statements and switch statements, which help in making decisions and performing different actions based on the conditions provided.
2.
How many types of conditions are there in problem-solving?
Correct Answer
B. 2
Explanation
There are two types of conditions in problem-solving.
3.
Multiple conditions have ______ kinds of logic.
Correct Answer
C. 3
Explanation
Multiple conditions have three kinds of logic.
4.
A single condition has __________ or __________.
Correct Answer(s)
A. Actions
C. Set of instructions
Explanation
A single condition can have a set of actions or a set of instructions associated with it. This means that when the condition is met, either a series of actions or a set of instructions will be executed. The actions or instructions can vary depending on the specific condition and the desired outcome.
5.
A programmer uses positive logic when he is telling the computer to follow a set of instructions and continue processing if the condition is True; If the condition is not True, then the computer processes another decision.
Correct Answer
A. True
Explanation
Positive logic is a programming approach where the computer follows a set of instructions and continues processing if a given condition is true. If the condition is not true, the computer proceeds with another decision. Therefore, the given statement accurately describes positive logic, making the answer "True" correct.
6.
The following are the kinds of multiple conditions, EXCEPT __________.
Correct Answer
D. Question logic
Explanation
The given answer suggests that "question logic" is not a kind of multiple condition. This implies that "question logic" does not fall under the category of different types of conditions such as straight-through logic, positive logic, and negative logic. However, without further context or information, it is difficult to provide a more detailed explanation.
7.
Decision logic structure use IF/Then/Else.
Correct Answer
A. True
Explanation
Decision logic structures use IF/Then/Else statements to determine the flow of a program based on certain conditions. These structures allow the program to make decisions and execute different sets of instructions depending on whether a condition is true or false. By using IF statements, the program can evaluate a condition and then execute a specific set of instructions if the condition is true. If the condition is false, the program can also execute a different set of instructions using the Else statement. Therefore, the statement "Decision logic structures use IF/Then/Else" is true.
8.
A programmer will use __________ to tell the computer to process another decision when the resultant of the condition is True; If the resultant is False, then the computer processes a consequent set of instructions and continues processing the module.
Correct Answer
C. Negative logic
Explanation
A programmer will use negative logic to tell the computer to process another decision when the resultant of the condition is False. If the resultant is True, then the computer processes a consequent set of instructions and continues processing the module. Negative logic involves using a logical NOT operator to invert the condition, so that when the condition is False, it becomes True and vice versa. This allows the programmer to control the flow of the program based on the opposite of the condition's outcome.
9.
A programmer will use __________ when all decisions have to be processed and when they are independent of each other.
Correct Answer
A. Straight-through logic
Explanation
A programmer will use straight-through logic when all decisions have to be processed and when they are independent of each other. This means that the program will simply execute each decision in a linear manner, without any branching or conditional statements. This approach is suitable when all decisions need to be processed regardless of their outcomes, and when the decisions do not affect each other's execution.
10.
Which flowchart symbol is used for decision or condition?
Correct Answer
A. Option 1
Explanation
The flowchart symbol used for decision or condition is represented by Option 1. This symbol typically takes the form of a diamond shape with two branches, one for the "yes" condition and one for the "no" condition. It is used to represent a point in the flowchart where a decision needs to be made based on a certain condition or criteria.
11.
A programmer will use __________ to execute the lines of code repeatedly.
Correct Answer
C. Looping logic structure
Explanation
A programmer will use looping logic structure to execute the lines of code repeatedly. Looping allows the programmer to repeat a specific set of instructions multiple times until a certain condition is met. This is useful when there is a need to perform a task iteratively or when a certain code block needs to be executed a fixed number of times. By using looping logic structure, the programmer can save time and effort by automating repetitive tasks and making the code more efficient.
12.
The following are the kinds of loops, EXCEPT __________.
Correct Answer
B. IF/Then/ Else
Explanation
The given options list different types of loops, including "for," "while," and "do-while." However, "IF/Then/Else" is not a type of loop but a conditional statement used for decision-making in programming. It is used to execute a block of code if a certain condition is true, otherwise, it executes a different block of code. Therefore, the correct answer is "IF/Then/Else" as it is not a kind of loop.
13.
The programmer will use do-while to repeat the lines of code at least one-time execution.
Correct Answer
A. True
Explanation
A do-while loop is a type of loop in programming that executes a block of code at least once, regardless of the condition being true or false. This is because the condition is checked at the end of the loop. Therefore, the statement that the programmer will use a do-while loop to repeat the lines of code at least one-time execution is true.
14.
__________ occurs when a module or a function calls itself.
Correct Answer
C. Recursion
Explanation
Recursion occurs when a module or a function calls itself. It is a programming technique that allows a problem to be solved by breaking it down into smaller subproblems of the same type. This can lead to elegant and concise code, as well as efficient problem-solving. Recursion is commonly used in algorithms such as tree traversal, searching, and sorting. By calling itself, a function can repeatedly solve smaller versions of the problem until a base case is reached, which terminates the recursion.
15.
__________ are logical variables that a programmer sets within a program to change the processing path or to control when the processing of a loop should end.
Correct Answer
A. Indicators
Explanation
Indicators are logical variables that a programmer sets within a program to change the processing path or to control when the processing of a loop should end. These variables act as flags and can be used to determine whether a certain condition has been met or not. By setting and checking the values of indicators, programmers can alter the flow of the program and make decisions based on the state of these variables. This allows for more flexible and dynamic control over the execution of the program.
16.
I++ is similar to __________.
Correct Answer
C. I = i + 1
Explanation
The correct answer is i = i + 1 because the "++" operator is known as the increment operator in programming. It increases the value of i by 1. Therefore, i++ is equivalent to i = i + 1.
17.
Which is the right syntax for the while loop?
Correct Answer
C. While (pizza <= 5) { cout << "text"; }
Explanation
The correct syntax for a while loop is "while (condition) { code }". In this case, the condition is "pizza
18.
Fill in the blanks to print x's values from 1 to 5. Increment x's value using the ++ operator.
int x = 1;
________
(x <= 5) {
cout << x << endl;
x________;
}
Correct Answer
while
++
Explanation
The code uses a while loop to print the values of x from 1 to 5. The condition for the while loop is that x is less than or equal to 5. Inside the loop, the value of x is printed using cout, and then x is incremented using the ++ operator. This means that x will increase by 1 in each iteration of the loop.
19.
Fill in the blanks to print x's values to the screen 10 times:
________
(int x = 1; x <= 10; ________ ++) {
cout << x << endl;
}
Correct Answer
for
x
Explanation
The correct answer is "for, x" because the question is asking for the missing elements in the code to print the value of x to the screen 10 times. The "for" loop is used to iterate over a block of code a specific number of times, and "x" is the variable that is being incremented each time the loop runs. This allows the code to print the value of x to the screen and continue looping until x reaches 10.
20.
Fill in the blanks to check if the age variable is greater than 18:
int age = 25;
________ (________> 18) {
cout << "Adult";
}
Correct Answer
if
age
Explanation
The if statement is used to check a condition, in this case whether the age variable is greater than 18. The variable "age" is being checked to see if it is greater than 18, and if it is, the statement "Adult" will be printed.