Question: What output can be expected after the following lines of pseudo code:
Declare Integer i, j
Set j = 10
Set i = i – j – j * 2
the value of i is
Answer: This will cause an error
Question: Given the following pseudo code, what is the value of var3?
Declare Integer var1, var2, var3
Set var1 = 23
Set var2 = 4
Set var3 = var1 + var2
Set var3 = var3 – var1 * 2
Answer: -19
Question: Given the following pseudo code, what is the value of number3?
Declare Integer number1, number2, number3
Set number1 = 23
Set number2 = 4
number3 = number1 % number2
Answer: 3
Question: What is the result of this expression?
6.0 / 3.0 + 1.0 * 4.0
Answer: 6.0
Question: Given the following pseudocode, which of the following statements will give the variable result the value 2.0?
Declare Integer myInt = 2
Declare lnteger yourInt = 4
Answer:
Declare Real result = 0
result = yourInt / myInt
Question: Which of the following pseudo code fragments has the correct syntax for reading an integer from the keyboard? Choose the best answer.
Answer:
Declare Integer myNumber
Display “Enter a number”
Input myNumber
Question: In pseudocode, the word that we use to make a variable constant is:
Answer: Constant
Question: What is true of variables? (Check ALL the right answers)
Answer: they have a name, they can be used to store data, the data in them can change, they have a data type, and their name should start.
Question: It is a tool and sometimes called as informal language that is used to write an algorithm but is not meant to be compiled or executed.
Answer: pseudocode
Question: Find and fix the error in following pseudocode:
1. Declare Integer num1, num2, result
2. Set num1 = 5
3. Set num2 = 10
4. Set num1 * num2 = result
5. Display result
Answer:
Line number 4 is responsible for an error. Fix the assignment statement as:
result = num1 *num2
Question: Write a pseudo code statement to declare a variable called hoursPay that can hold hourly pay rate. In the next statement, set the value of the variable to 25.50
Answer:
Declare Real hoursPay
Set hoursPay = 25.50
Question: In a math expression, multiplication and division take place before addition and subtraction.
Answer: True
Question: According to the pseudocode standards being followed for this course, is it an error not to include a data type of the variable in the declaration statement?
Answer: True
Question: Given the expression 12 + 7
What are the values on the right and left of the + symbol called?
Answer: operands
Question: Which operator performs division, but instead of returning the quotient it returns the remainder?
Answer: modulus
Question: Consider the identifiers:
i) fr6uit
ii) 1name
iii) name2
iv) student number
v) studentNumber
Which ones are good variable names that obey both the rules of pseudo code syntax and the naming conventions?
Answer: i, iii, v
Question: What is the major difference between an Integer and a Real? Choose the best answer.
Answer: One can store numbers with fractions and the other cannot.
Question: Which of the following is not a word used to declare or initialize or print a variable in pseudocode?
Answer: Output
Question: Pseudo code a statement that ask for a Real number as input from keyboard.
Answer:
Declare Real myInput
Display “What is your decimal?”
Input myInput
Question:
Given the following initialized variables:
Declare Integer num1, num2,num3
Set num1 = 2
Set num2 = 3
Set num3 = 4
Match the following operations with expected outputs.
Answer:
num1 * num1 * num2 * num2 : 36
num2 – num1 + num3 – num1 : 3
num3 / num1 : 2
num3 % num1 : 0