1.
Which of the following is NOT a type of algorithm?
Correct Answer
A. Program
Explanation
A program is not a type of algorithm. An algorithm is a step-by-step procedure or set of rules for solving a problem, while a program is a set of instructions written in a specific programming language to be executed by a computer. Although a program may implement an algorithm, it is not considered a type of algorithm itself. Flowchart, decision table, and pseudocode, on the other hand, are different ways to represent algorithms.
2.
The symbol that represents comments in a flowchart is
Correct Answer
B. An annotation symbol
Explanation
An annotation symbol is the correct answer because it is used in flowcharts to provide additional information or explanations about the flowchart or specific parts of it. It is typically represented by a rectangle with a dashed or dotted line, and it contains text that describes the purpose or functionality of the associated flowchart element. This symbol helps in enhancing the clarity and understanding of the flowchart by providing relevant comments or notes.
3.
The part of a decision table in which all the conditions, based on which a decision is made are written is:
Correct Answer
B. Condition Stub
Explanation
The condition stub is the part of a decision table where all the conditions, based on which a decision is made, are written. It represents the set of conditions that need to be evaluated to determine the appropriate action to take. The condition stub acts as a placeholder for the conditions and helps organize the decision table by clearly defining the conditions that need to be considered.
4.
In a flowchart the symbol that represents a condition based on which a decision should be made is
Correct Answer
C. Decision
Explanation
A flowchart is a graphical representation of a process or algorithm, where different symbols are used to depict different actions or steps. In this context, the symbol that represents a condition based on which a decision should be made is called a "Decision" symbol. This symbol is typically represented as a diamond shape in a flowchart. When the flowchart reaches a decision symbol, it evaluates a condition or criteria and based on the result, it determines which path to follow next in the flowchart.
5.
Which symbol on a flowchart is used to represent the connection between the portions of a flowchart on separate pages?
Correct Answer
A. Off-Page Connector
Explanation
An off-page connector is used to represent the connection between the portions of a flowchart on separate pages. This symbol indicates that the flowchart continues on a different page and helps to maintain the flow and organization of the chart. It is commonly used when the flowchart becomes too complex to fit on a single page and allows for easier navigation and understanding of the process.
6.
Which of the following statements is False?
Correct Answer
B. The input, process, output, and display symbols should have only one flow line.
Explanation
The input, process, output, and display symbols can have multiple flow lines as they represent different steps in the flowchart.
7.
Which of the following statements is true?
Correct Answer
C. Flowcharts are a better method of communicating logic than pseudocode and decision tables
Explanation
Flowcharts are a better method of communicating logic than pseudocode and decision tables because flowcharts provide a visual representation of the steps and decision points in a program, making it easier to understand the flow of logic. Pseudocode and decision tables, on the other hand, are more abstract and may require a deeper understanding of programming concepts to interpret. Additionally, flowcharts allow for easier identification of errors or inefficiencies in the logic, as they provide a clear visual representation of the program's structure.
8.
____________ represent algorithms that involve complex decision-making.
Correct Answer
B. Decision Tables
Explanation
Decision Tables represent algorithms that involve complex decision-making. They are used to model complex logic and conditions in a structured and organized manner. Decision Tables provide a visual representation of all possible combinations of conditions and corresponding actions or outcomes. This allows for a systematic approach to decision-making and helps in identifying the most appropriate action based on various conditions. Therefore, Decision Tables are a suitable choice for representing algorithms that involve complex decision-making.
9.
What are the four components of a Decision Table? (Choose all that apply)
Correct Answer(s)
B. Condition Stub
C. Action Stub
D. Condition Applied
E. Action Taken
Explanation
A Decision Table is a tabular representation of different conditions and corresponding actions. The four components of a Decision Table are: Condition Stub, which lists all the possible conditions or inputs; Action Stub, which lists all the possible actions or outputs; Condition Applied, which specifies the conditions that are relevant to each action; and Action Taken, which specifies the actions that are taken based on the conditions. These components help in organizing and analyzing complex decision-making processes.
10.
The accept keyword in a pseudocode is similar to the _____________ symbol in a flowchart.
Correct Answer
B. Input
Explanation
The accept keyword in pseudocode is used to indicate that the program should wait for user input. Similarly, the "Input" symbol in a flowchart represents the action of receiving input from the user. Both the accept keyword and the "Input" symbol serve the same purpose of allowing the program to interact with the user and obtain input values.
11.
How would you declare a variable to store the gender of a person?
Correct Answer
C. Character cGender
Explanation
The correct answer is "character cGender" because the question asks for a variable to store the gender of a person. The data type "character" is appropriate for storing a single character, which can represent the gender of a person (e.g., "M" for male, "F" for female). The variable name "cGender" is also suitable as it is clear and descriptive.
12.
A nAge variable is declared to store the age of a person. How would you intialize the variable to 25? (Choose all that apply)
Correct Answer(s)
B. NAge = 25
D. Display "Enter the age" Accept nAge
Explanation
The correct answers are "nAge = 25" and "Display 'Enter the age' Accept nAge".
- "nAge = 25" assigns the value 25 to the variable nAge, initializing it to 25.
- "Display 'Enter the age' Accept nAge" prompts the user to enter the age and accepts the input into the variable nAge. This also initializes nAge to 25 if the user enters 25.
13.
A variable used to store the name of customers is to be declared. Which of the following declares the variable and intializes it to Tom? (Choose all that apply)
Correct Answer
B. String nName = "Tom"
Explanation
In programming, string values are typically enclosed in double quotation marks to indicate that they are strings. So, the correct syntax is to use double quotation marks around "Tom" as shown in the example above.
14.
Which of the following is/are valid variable name/s? (Choose all that apply)
Correct Answer(s)
B. NBasicSalary
D. NBasic_Salary
Explanation
The valid variable names in the given options are "nBasicSalary" and "nBasic_Salary". Variable names can consist of letters, numbers, and underscores, but they cannot start with a number or contain spaces or special characters like periods. Therefore, "nBasic Salary" and "nBasic.Salary" are not valid variable names. "Basic Salary" is also not a valid variable name as it contains a space.
15.
Indicate whether the following statements are true or false. Statement 1: A variable needs to be declared before being used in a program Statement 2: A variable can be used without being initialized.
Correct Answer
C. Statement 1 is True and Statement 2 is false
Explanation
In programming, it is necessary to declare a variable before using it, as stated in Statement 1. This means that the variable's type and name must be specified before it can be used in the program. On the other hand, Statement 2 is false because a variable cannot be used without being initialized. Initialization refers to assigning a value to the variable before it is used. Therefore, the correct answer is that Statement 1 is true and Statement 2 is false.
16.
In the following expression
z = x + y
x and y are called:
Correct Answer
C. Operands
Explanation
In the given expression, "z = x + y," x and y are referred to as operands. Operands are the variables or values that are used in an operation or calculation. In this case, x and y are the values being added together to calculate the value of z.
17.
Study the following pseudocode -
begin numeric nNum1, nNum2, nNum3 nNum1 = 20 nNum2 = 4 nNum3 = nNum1 % nNum2 Display nNum3 end
What will be the output?
Correct Answer
A. 0
Explanation
The output will be 0 because the % operator in programming represents the modulus operation, which calculates the remainder when one number is divided by another. In this case, nNum1 (20) is divided by nNum2 (4), and the remainder is 0. Therefore, the value of nNum3 will be 0, and it will be displayed as the output.
18.
Which operators are used to test the relationship between two variables or between a variable and a constant?
Correct Answer
C. Relational operators
Explanation
Relational operators are used to test the relationship between two variables or between a variable and a constant. These operators compare the values of the variables or constants and return a boolean value (true or false) based on the comparison. Examples of relational operators include ">", "=", "
19.
Which of the following is a logical operator?
Correct Answer
B. And
Explanation
The logical operator "And" is used to combine two conditions in a logical expression. It returns true if both conditions are true, and false otherwise. This operator is commonly used in programming languages to create complex conditional statements and to control the flow of a program based on multiple conditions.
20.
If an expression contains an addition operator, a less than operator, and a subtraction operator, which operator has a higher priority when evaluating the expression?
Correct Answer
C. Less than operator
Explanation
In expressions with multiple operators, the order of operations determines the priority. Comparison operators, such as the less than operator (<), have a higher precedence than both addition (+) and subtraction (-) operators.
When evaluating an expression with a less than operator, it is evaluated after any addition or subtraction has occurred, but its result is prioritized when comparing values. The addition and subtraction operators have equal priority but lower than comparison operators.
21.
Which of the following is/are relational operators? (Choose all that apply)
Correct Answer(s)
A. =
C. !=
D. <=
Explanation
Relational operators are used to compare values and determine the relationship between them. These operators include "=", "!=", and "<=".
"=" is used for equality comparison, "!=", for inequality comparison, and "<=" for less than or equal to comparison.
The "%" operator is the modulus operator used for finding the remainder of a division operation and is not a relational operator. Similarly, the "*" operator is the multiplication operator and is not a relational operator.
22.
If x=2 NOT x=3 will result in:
Correct Answer
A. True
Explanation
If x=2, it means that the value of x is 2. The statement "NOT x=3" means that x is not equal to 3. Since x is indeed 2 and not 3, the statement "x=2 NOT x=3" is true.
23.
Which operator has the highest precedence level?
Correct Answer
A. ()
Explanation
The parentheses operator () has the highest precedence level. This means that any expression within parentheses will be evaluated first before any other operators. It is used to group subexpressions and override the default order of evaluation. By using parentheses, we can control the order in which operations are performed and ensure that certain calculations are prioritized.
24.
What is the result of the following pseudocode? begin numeric nNum1, nNum2, nNum3, nResult nNum1 = 8 nNum2 = 9 nNum3 = 10 nResult = nNum1+nNum2*nNum3/45+15 Display nResult end
Correct Answer
D. 25
Explanation
The pseudocode calculates the value of nResult by performing a series of arithmetic operations. First, it multiplies nNum2 and nNum3, resulting in 90. Then, it divides the product by 45, resulting in 2. Finally, it adds nNum1 and the previous result, resulting in 25. Therefore, the correct answer is 25.
25.
What are the values of nNum1 and nNum2 after the following program executes? begin numeric nNum1=2 numeric nNum2=3 numeric nSwap nSwap = nNum1 nNum1 = Num2 nNum2 = Num1 end
Correct Answer
C. NNum1 = 3, nNum2 = 2
Explanation
Let's go through the code step by step:
nNum1 = 2 and nNum2 = 3 are initialized.
nSwap = nNum1 stores the value of nNum1 (which is 2) in the variable nSwap.
nNum1 = Num2 (this line seems to have a typo; it should be nNum1 = nNum2). So, this assigns the value of nNum2 (which is 3) to nNum1. Now, nNum1 = 3.
nNum2 = Num1 (again, there seems to be a typo, but it should mean nNum2 = nSwap). This assigns the value stored in nSwap (which is 2) to nNum2. Now, nNum2 = 2.
Thus, after the program executes, nNum1 = 3 and nNum2 = 2.
26.
If 6 and 4 were entered respectively for number 1 and number 2 then what will be displayed when the following program executes?
begin
numeric nNum1, nNum2, nResult
display “Enter number1 and number2
accept nNum1
accept nNum2
nResult = nNum1 + nNum2
if(nResult % 2 = 0)
begin
display “The result is even”
end
else
begin
display “The result is odd”
end
end
Correct Answer
A. The result is even
Explanation
When the program executes, it first prompts the user to enter number 1 and number 2. The values 6 and 4 are then entered respectively for number 1 and number 2. The program then calculates the sum of number 1 and number 2, which is 10. Since 10 is an even number, the condition in the if statement is true, and the program displays "The result is even". Therefore, the correct answer is "The result is even".
27.
Is the following statement true or false?
Statement: if constructs and switch...case constructs are decision-making constructs
Correct Answer
B. True
Explanation
The statement is true because both if constructs and switch...case constructs are decision-making constructs in programming. The if construct allows for conditional execution of code based on a true or false condition, while the switch...case construct allows for multiple possible paths of execution based on the value of a variable or expression. Therefore, both constructs are used to make decisions and control the flow of a program.
28.
Is the following statement true or false?
Statement: The switch construct consists one case statement, a number of switch instructs, and a default statement
Correct Answer
A. False
Explanation
The statement is false because the switch construct consists of one case statement, a number of case labels, and a default statement. The switch instructs mentioned in the statement are not part of the switch construct.