Question: 1:True or False: Some For loops cannot be rewritten as While loops 2:In the pseudocode below: Function Integer perfect(Integer n) Declare Integer count = 0
1:True or False: Some For loops cannot be rewritten as While loops
2:In the pseudocode below:
Function Integer perfect(Integer n) Declare Integer count = 0 Declare Integer sum = 0 While count < n Set count = count + 1 Set sum = sum + count End While Return sum End Function Function Integer perfect_sum(Integer n) Declare Integer count = 0 Declare Integer sum = 0 While count < n Set count = count + 1 Set sum = sum + perfect(count) End While Return sum End Function Module main() Display perfect_sum(5) End Module
What will be the output when the main module is called (separate each output with a single space)?
Hint: You may find it easier to write a Python program to calculate the above instead of trying to work out the answer on paper. Whichever way you find easier is acceptable.
3:
What will the output be for the following pseudocode:
Declare Integer counter = 1 While counter < 10 Set counter = counter + 2 Display counter End While
Separate each output with a single space.
4:
Boolean variables are commonly used as _______, which indicate whether a specific condition exists.
Question 13 options:
| output variables | ||||||||||||||||||||||||||||||||||||||||||
| while loops | ||||||||||||||||||||||||||||||||||||||||||
| flags | ||||||||||||||||||||||||||||||||||||||||||
| unconditional expressions | ||||||||||||||||||||||||||||||||||||||||||
| input variables
5: In the pseudocode below: Module fibo(Integer n) Declare Integer first = 1 Declare Integer second = 1 Declare Integer next = 0 Declare Integer counter = 0 While counter < n Set counter = counter + 1 Set next = first + second Set first = second Set second = next Display next End While End Module What will be the output from calling fibo(5) (separate each output with a single space)? Hint: You may find it easier to write a Python program to calculate the above instead of trying to work out the answer on paper. Whichever way you find easier is acceptable. 6: In the pseudocode below: Function Integer fibo_2(Integer n) If n == 1 Then Return 1 Else If n == 2 Then Return 1 Else Return fibo_2(n - 1) + fibo_2(n - 2) End If End Function Module loop(Integer n) Declare Integer counter = 0 While counter < n counter = counter + 1 Display fibo_2(counter) End While End Module What will be the output from calling loop(6) (separate each output with a single space)? Hint: You may find it easier to write a Python program to calculate the above instead of trying to work out the answer on paper. Whichever way you find easier is acceptable. 7: What kind of loop is this? Declare Integer counter counter = 0 Do Display counter counter = counter + 1 Until counter > 10
Question 18 options:
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
