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, 22.06.2019 06:00
Pthe price of tickets in a group when a purchased in bulk can be found with the equation c=px+24 were c is the cost, p is the number of people,and x is the price per ticket. what is price of of each ticket if it costs $189 to buy tickets for 15 people ? a $8 b $24c $9d $11 show work
Answers: 1
question
Computers and Technology, 22.06.2019 10:00
Wich technology can a website use to allow you to listen to a concert live over the internet?
Answers: 3
question
Computers and Technology, 22.06.2019 12:00
Which of the following “invisible” marks represents an inserted tab?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 1
You know the right answer?
Consider the following code segment. The code is intended to read nonnegative numbers and compute th...
Questions
question
History, 15.12.2021 14:00
question
Mathematics, 15.12.2021 14:00
question
English, 15.12.2021 14:00
question
Arts, 15.12.2021 14:00
Questions on the website: 13722367