subject

Consider the following code segment. The code is intended to read nonnegative numbers and compute their product until a negative number is read. However it does not work as intended. Assume that the readInt method correctly reads the next number from the input

stream. int k = 0;int prod = 1;while (k>=0){System. out. println("Enter a number: ");k= readInt( );prod = prod*k;}System. out. println("product: "+prod);

Which of the following best describes the error in the program?

A. The variable prod is incorrectly initialized
B. The while condition always evaluates to false
C. The while condition always evaluates to true
D. The negative number entered to signal no more input is included in the product
E. If the user enters a zero, the computation of the product will be terminated prematurely

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:30
On early television stations, what typically filled the screen from around 11pm until 6am? test dummies test patterns tests testing colors
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
What are the most commonly found items in the trash according to the municipal solid waste report?
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
You know the right answer?
Consider the following code segment. The code is intended to read nonnegative numbers and compute th...
Questions
question
Mathematics, 23.04.2020 21:33
question
Mathematics, 23.04.2020 21:33
question
Mathematics, 23.04.2020 21:33