Which statement is correct about the execution of the loop in the following code fragment?
Double num;
Int incr = 0;
Scanner reader = new Scanner(System.in) ;
Do
{
Incr = incr + 1;
System.out.println("Please enter a number (0 when done) : ") ;
Num = reader.nextDouble() ;
}
While (num != 0) ;
System.out.println("" + incr) ;
A) The loop will execute only when 0 is entered.
B) The execution of the loop is independent of user input.
C) The program prints the count of positive inputs.
D) The loop will execute at least once even if the user has entered the sentinel value.
Correct Answer:
Verified
Q27: What is the output of the code
Q62: How many times is the text "Let's
Q71: How many times does the following loop
Q80: Suppose that the chance to hit the
Q81: Which of the following code snippets will
Q87: Is the following code snippet legal?
Boolean b
Q88: What will be the output of the
Q89: Is the code snippet written below legal?
String
Q95: What is the last output line of
Q115: In the following code snippet, when does
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents