What is the termination condition for the following While loop? while (beta > 0
ID: 3553046 • Letter: W
Question
What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; } beta > 0 && beta < 10 beta >= 0 && beta <= 10 beta < 0 || beta > 10 beta <= 0 || beta >= 10 === Indicate where (if at all) the following loop needs a priming read. count = 1; // Line 1 while (count <= 10) // Line 2 { // Line 3 cin >> number; // Line 4 cout << number * 2; // Line 5 counter++; // Line 6 } // Line 7 between lines 1 and 2 between lines 3 and 4 between lines 5 and 6 between lines 6 and 7 No priming read is necessary. === Give the input data 25 10 6 -1 What is the output of the following code fragment? (All variables are of type int.) sum = 0; cin >> number; while (number != -1) { cin >> number; sum = sum + number; } cout << sum << endl; 15 41 40 16 no output--this is an infinite loop ==== After execution of the following code, what is the value of length? (count and length are of type int.) length = 5; count = 4; while (count <= 6) { if (length >= 100) length = length - 2; else length = count * length; count++; } 600 100 98 20 none of the above ==== What is the output of the following code fragment? (finished is a Boolean variable, and firstInt and secondInt are of type int.) finished = FALSE; firstInt = 3; secondInt = 20; while (firstInt <= secondInt && !finished) { if (secondInt / firstInt <= 2) // Reminder: integer division finished = TRUE; else firstInt++; } cout << firstInt << endl; 3 5 7 8 9 ==== In the following code fragment, a semicolon appears at the end of the line containing the While condition. cout << 'A'; loopCount = 1; while (loopCount <= 3); { cout << 'B'; loopCount++; } cout << 'C'; The result will be: the output AC the output ABC the output ABBBC a compile-time error an infinite loop ====== What is the output of the following code fragment? (All variables are of type int.) sum = 0; outerCount = 1; while (outerCount <= 3) { innerCount = 1; while (innerCount <= outerCount) { sum = sum + innerCount; innerCount++; } outerCount++; } cout << sum << endl; 1 4 10 20 35 ==== In the C++ program fragment count = 1; while (count < 10) count++; cout << "Hello"; the output statement that prints "Hello" is not part of the body of the loop. True False ==== In C++, an infinite loop results from using the assignment operator in the following way: while (gamma = 2) { . . . } True False ==== The body of a do...while loop is always executed (at least once), even if the while condition is not satisfied: True False ===== What is the out put of the following c++ code fragment? int count = 3; while (count-- > 3) cout << count<<" " ; 1 2 3 0 1 2 3 2 1 2 1 0 none of above.this code fragment returns a syntax error. ==== what is the out put of the following code fragment: int count = 3; while (-- count > 0) cout<< count<<" "<<endl; 0 1 2 2 1 0 1 2 2 1 none of the above.this loop returns a syntax error. Explanation / Answer
What is the termination condition for the following While loop?
while (beta > 0 && beta < 10)
{
cout << beta << endl;
cin >> beta;
}
Answer :beta <= 0 || beta >= 10
===
Indicate where (if at all) the following loop needs a priming read.
count = 1; // Line 1
while (count <= 10) // Line 2
{ // Line 3
cin >> number; // Line 4
cout << number * 2; // Line 5
counter++; // Line 6
} // Line 7
Answer: No priming read is necessary.
===
Give the input data
25 10 6 -1
What is the output of the following code fragment? (All variables are of type int.)
sum = 0;
cin >> number;
while (number != -1)
{
cin >> number;
sum = sum + number;
}
cout << sum << endl;
Answer: 16
====
After execution of the following code, what is the value of length? (count and length are of type int.)
length = 5;
count = 4;
while (count <= 6)
{
If (length >= 100)
length = length - 2;
else
length = count * length;
count++;
}
Answer: 98
====
What is the output of the following code fragment? (finished is a Boolean variable, and firstInt and secondInt are of type int.)
finished = FALSE;
firstInt = 3;
secondInt = 20;
while (firstInt <= secondInt && !finished)
{
if (secondInt / firstInt <= 2) // Reminder: integer division
finished = TRUE;
else
firstInt++;
}
cout << firstInt << endl;
Answer : 9
====
In the following code fragment, a semicolon appears at the end of the line containing the While condition.
cout << 'A';
loopCount = 1;
while (loopCount <= 3);
{
cout << 'B';
loopCount++;
}
cout << 'C';
The result will be: an infinite loop
the output AC
the output ABC
the output ABBBC
a compile-time error
an infinite loop
======
What is the output of the following code fragment? (All variables are of type int.)
sum = 0;
outerCount = 1;
while (outerCount <= 3){1 2 3
innerCount = 1;
while (innerCount <= outerCount)
{
sum = sum + innerCount;
innerCount++;
}
outerCount++;
}
cout << sum << endl;
Answer: 10
====
In the C++ program fragment
count = 1;
while (count < 10)
count++;
cout << "Hello";
the output statement that prints "Hello" is not part of the body of the loop.
Answer: True
====
In C++, an infinite loop results from using the assignment operator in the following way:
while (gamma = 2)
{
. . .
}
Answer: True
====
The body of a do...while loop is always executed (at least once), even if the while condition is not satisfied:
Answer True
=====
What is the output of the following C++ code fragment?
int count = 3;
while (count-- > 3)
cout << count<<" " ;
Answer: none of above
====
what is the output of the following code fragment:
int count = 3;
while (-- count > 0)
cout<< count<<" "<<endl;
Answer: 2 1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.