# computer science

posted by .

write a program that prompts the user to input three numbers. The program should then output the numbers in nondescending order.

• computer science -

Week 4: Iteration and Repetition - Exercises Help

________________________________________

________________________________________

1. (TCO 5) The following is what type of loop?
Declare Integer n = 1
Declare Integer s = 0
Declare Integer number
Declare String keepGoing = "y"
While keepGoing == "y"
Display "Enter an integer."
Input number
Set s = s + number
Set n = n + 1
Display "Keep going? (Enter y or yes or n for no.)"
Input keepGoing
End While
(Points: 1)
count controlled pre-test
count controlled post-test
condition controlled pre-test
condition controlled post-test

2. (TCO 5) Which variable is the accumulator for the following loop?
Declare Integer n = 1
Declare Integer s = 0
Declare Integer number
Declare String keepGoing = "y"
While keepGoing == "y"
Display "Enter an integer."
Input number
Set s = s + number
Set n = n + 1
Display "Keep going? (Enter y or yes or n for no.)"
Input keepGoing
End While
(Points: 1)
n
s
number
keepGoing

3. (TCO 5) Which variable is the counter for the following loop?
Declare Integer n = 1
Declare Integer s = 0
Declare Integer number
Declare String keepGoing = "y"
While keepGoing == "y"
Display "Enter an integer."
Input number
Set s = s + number
Set n = n + 1
Display "Keep going? (Enter y for yes or n for no.)"
Input keepGoing
End While
(Points: 1)
n
s
number
keepGoing

4. (TCO 5) To which variable is the sentinel value assigned in the following loop?
Declare Integer n = 1
Declare Integer s = 0
Declare Integer number
Declare String keepGoing = "y"
While keepGoing == "y"
Display "Enter an integer."
Input number
Set s = s + number
Set n = n + 1
Display "Keep going? (Enter y for yes or n for no.)"
Input keepGoing
End While
(Points: 1)
n
s
number
keepGoing

5. (TCO 5) If the user enters 3, y, 6, y, 7 and n when prompted, what will be displayed by the pseudocode program?
Declare Integer n = 0
Declare Integer s = 0
Declare Integer number
Declare String keepGoing = "y"
While keepGoing == "y"
Display "Enter an integer."
Input number
Set s = s + number
Set n = n + 1
Display "Keep going? (Enter y for yes or n for no.)"
Input keepGoing
End While
Display n, " ", s
(Points: 1)
7 7
3 16
4 16
7 16

6. (TCO 5) Assume the user enters 3 when prompted to enter the number of values. What value will be displayed by the pseudocode program?
Declare Integer counter = 1
Declare Integer maxValue
Declare Integer s = 0
Display "Enter the number of values"
input maxValue
While counter <= maxValue
Set s = s + 2
End While
Display s
(Points: 1)
2
6
8
No value will be displayed, it is an infinite loop

7. (TCO 5) What value will be displayed by the following pseudocode program?
Declare Integer counter
Declare Integer accumulator = 0
For counter = 1 to 3
Set accumulator = accumulator + counter
End For
Display accumulator
(Points: 1)
9
6
3
0

8. (TCO 5) Which type of loop will always execute at least once? (Points: 1)
While
For
Do-While
Any pretest loop

9. (TCO 5) Which of the following is not found in a For loop? (Points: 1)
sentinel
counter
accumulator
loop body

10. (TCO 5) One of the following four types of loops can be used for any repetition structure needed in a program. (Points: 1)
For loop
While loop
Do-While loop
Do-Until loop

________________________________________

## Respond to this Question

 First Name School Subject Your Answer

## Similar Questions

1. ### Computer - Programming

Please do help in providing solution to this question, thanks: Write a Fortran program that requests for three numbers from the keyboard, subtracts 48 from their sum and then divides the result by 6 before sending the output to the …
2. ### Computer Science

1.Write an Assembly program that reads in a number of cents. The program will write out the number of dollars and cents separately. Sample Run: ?
3. ### computer science

Write a program that prompts the user to input three numbers. The program should then output the numbers in non-descending order
4. ### Computer Science

The digits 0, 1, and 8 look much the same if rotated 180 degrees on the page (turned upside down). Also, the digit 6 looks much like a 9, and vice versa, when rotated 180 degrees on the page. A multi-digit number may also look like …
5. ### Computer Science

The digits 0, 1, and 8 look much the same if rotated 180 degrees on the page (turned upside down). Also, the digit 6 looks much like a 9, and vice versa, when rotated 180 degrees on the page. A multi-digit number may also look like …
6. ### Programming

I need your help to write a program using visual basic 2010 for the following:- write a program that calculates the average of up to 50 numbers input by the user and stored in an arrey. The program should use a class named Statistics …
7. ### computer science

Class scores: Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the …
8. ### programming

Using Raptor, create a condition loop that will ask the user for input of two numbers. The numbers should be added and the sum displayed. The loop should also ask the user if he or she wishes to enter two more numbers and perform the …
9. ### programming

Create the logic for a program that prompts a user for three numbers and stores them in an array. Pass the array to a method that reverses the order of the numbers. Display the reversed numbers in the main program.
10. ### programming

Using python write a program that does the following: •Create the logic for a program whose main() method prompts a user for 1000 numbers and stores them in a list. •Pass the array to a method that reverses the order of the numbers. …

More Similar Questions