Ask Question
15 December, 14:41

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. 15 December, 17:42
    0
    The answer to the problem is 5
Know the Answer?
Not Sure About the Answer?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers