Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The while loop is a poattest loop. A loop that never stops is called a(n) loop.

ID: 3564967 • Letter: T

Question

The while loop is a poattest loop. A loop that never stops is called a(n) loop. A specific value that is used to mark the end of a list, so that a loop may stop may stop is called a(n) What will be the output of the following code segment? What is the output of the following C++ code segment? Write a code segment that uses a while loop to count how many integers are entered before the user enters -1. Then print how many numbers were entered (not counting the -1 ). Be sure to define any variables be sure to define any variables

Explanation / Answer

1) False

2) Infinite

3) Sentinal

4) 32

5) x = 1, y = 3


6)

#include<iostream>
using namespace std;

int main()
{
   int count = 0, input;
  
   cout<<"Enter number or -1 to stop"<<endl;
   while(1)
   {
       cin>>input;
      
       if(input == -1)
       {
           break;
  
       }
      
       else
       {
           count++;
       }
      
   }

   cout<<" Total Numbers entered : "<<count<<endl;
  
}