Ask Question
27 September, 06:00

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;

}

+1
Answers (1)
  1. 27 September, 06:14
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers