give s the value 0
give k the value 1
repeat the two statements while k < 5:
replace the value of s with s+k
replace the value of k with k+1
print s
that assigns values to the variables s and k.
What final value for s does the algorithm print?
1. 15
2. 10
3. 12
4. 5
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
s,k for each iteration:
0,1
1,2
3,3
6,4
10,5
10
s becomes 1, then 2, then 3, then 4, then 5. You don't add the values of s together, so it would just print 5.