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 15:00
Which of the following has not been attributed at least in part to social media a. drug addiction b. depression c. kidnapping d. murder
Answers: 2
question
Computers and Technology, 22.06.2019 15:30
What is a costume plot? why is it important to a film or theater production?
Answers: 2
question
Computers and Technology, 23.06.2019 03:30
In vista and windows 7, the appearance and personalization option allows you to change the
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
What process should be followed while giving a reference? sam has given a reference of his previous manager in his resume. sam should him in advance that the potential employers will him.
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
Mathematics, 17.01.2020 13:31
Questions on the website: 13722363