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 variablesExplanation / 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;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.