What is the sentinel value in the following code snippet? public static void main(String[] args)
{
Int age = 0;
Int sumOfAges = 0;
Int stop = 1;
Scanner reader = new Scanner(System.in) ;
System.out.println("Enter an age (-1 to stop) : ") ;
Age = reader.nextInt() ;
While (age != -1)
{
SumOfAges = sumOfAges + age;
System.out.println("Enter an age (-1 to stop) : ") ;
Age = reader.nextInt() ;
}
System.out.println("Sum of ages " + sumOfAges) ;
Return 0;
}
A) 0
B) 1
C) 2
D) -1
Correct Answer:
Verified
Q62: Which of the following statements is correct
Q88: Which statement is correct about the execution
Q89: How do you fix this code snippet
Q90: What will be the final output of
Q91: When will the loop in the following
Q92: What is the outcome of the following
Q95: What is the last output line of
Q96: Insert a statement that will correctly terminate
Q97: When designing storyboards, it is a good
Q98: What is the output of this code
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