Ask Question
23 November, 04:54

What is the sentinel value in the following code snippet?

public static void main (String[] args)

{

int age = 0;

int sum_of_ages = 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)

{

sum_of_ages = sum_of_ages + age;

System. out. println ("Enter an age (-1 to stop) : ");

age = reader. nextInt ();

}

System. out. println ("Sum of ages " + sum_of_ages);

return 0;

}

+5
Answers (1)
  1. 23 November, 05:41
    0
    The answer to the problem is 5
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “What is the sentinel value in the following code snippet? public static void main (String[] args) { int age = 0; int sum_of_ages = 0; int ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers