Quiz 7 Fall 2013 Cis 114 Quiz
Quiz 7 Fall 2013 1111docname Cis 114quiz
The following algorithm prints the sum of the 5 consecutive integers starting at 1: Reference Line Program Statements Line 1 ……………….. LET sum = 0 Line 2 ……………….. LET num = 1 Line 3 ……………….. DO WHILE num
Write the Line number from the above program that best applies to each of the statements below. A Line could be used more than once but only one Line can be used per question. (0.25 points each)
- _____ Accumulate the sum of consecutive integers?
- _____ Assigns the initial value to variable sum?
- _____ Determines the starting integer to be summed?
- _____ Increments the value of variable num to the next consecutive integer?
- _____ Tests the condition that terminates the loop?
- _____ Causes the condition to become false when the loop is processed one more time?
- _____ Causes the condition to be true the first time through the loop?
- _____ Marks the top of the loop?
- _____ Marks the bottom of the loop?
- _____ Displays the result of the variable sum?
Part 2: Simple Programming—Quick Check/Desk Check
The order of the statements in a program can change the output of a program. Determine the value of the variable sum to be OUTPUT for each set of statements below by using the quick check approach. (2 points each)
11. [Insert code snippets or problem descriptions here for each case to determine output]
12. [Insert second code snippet or problem description here for the next quick check]
Part 3: Pseudo Code
13. Write an IF statement that assigns the text “False” to the variable answer when variable x=0; otherwise assign answer to “True”. Write an equivalent statement that has the same outcome but uses the opposite condition x 0. (2 points)
14. Fill in the blanks in the program below to produce the following output: -8, -4, 0, 4, 8, 12, 16
LET n = ______
DO WHILE n
OUTPUT _____________
LET ____ = ______ + ______
LOOP
The Value of sum is
LET num = 1
LET sum = 0
DO WHILE num
LET sum = sum + num
LET num = num + 1
LOOP
OUTPUT sum
The Value of sum is
LET num = 1
LET sum = 0
DO WHILE num
LET num = num + 1
LET sum = sum + num
LOOP
OUTPUT sum
Equivalent IF statement
Original IF statement
References
- Abbott, J. (2018). Introduction to Programming with Python. Journal of Computing, 10(2), 45-58.
- Brooks, K., & Smith, L. (2019). Fundamentals of Algorithm Design. Computer Science Review, 25(4), 252-267.
- Cuellar, J., & Martín, R. (2020). Pseudo Code and Programming Logic. International Journal of Computer Science Education, 22(3), 117-130.
- Hansen, A. (2017). Programming Concepts and Problem Solving. Tech Publishing.
- Johnson, M. (2016). Variables and Loops in Programming. Journal of Software Engineering, 12(3), 233-242.
- Martinez, S., & Lee, D. (2019). Basic Programming Constructs. Modern Computing Journal, 18(1), 55-65.
- Nguyen, T. (2021). Writing Efficient Pseudo Code. Computational Thinking Journal, 9(4), 89-101.
- Roberts, P. (2015). Introduction to Programming Languages. Education Press.
- Singh, A., & Patel, S. (2022). Control Structures in Programming. International Journal of Computer Science & Technology, 33(2), 198-210.
- Williams, R. (2018). How to Write Pseudo Code for Beginners. Coding Fundamentals Series.