Question

2. What is the output of the following code fragment? n = 1; while (n <=...

2. What is the output of the following code fragment?

n = 1;
while (n <= 5)
{
n++;
cout << n << ' ';

a.1 2 3 4 5

b. 1 2 3 4

c. 1 1 1 forever

d. 2 3 4 5

e. 2 3 4 5 6

3. What is the termination condition for the following While loop?

while (beta > 0 && beta < 10)
{
cout << beta << endl;
cin >> beta;
}

a. beta > 0 && beta < 10

b. beta >= 0 && beta <= 10

c. beta < 0 || beta > 10

d. beta <= 0 || beta >= 10

4. Loop ____________________ is the moment that the flow of control reaches the first statement inside the loop body.

5. True or False? In testing a loop, one tries to devise data sets that leave the files in improper states that violate either the loop postcondition (an assertion that must be true immediately after the loop exit) or the postcondition of the module containing the loop.

6. These three common programming tasks _________________ __________________ _____________________ are often performed in a loop.

7. Given 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;

a. 15

b. 41

c. 40

d. 16

e. no output--this is an infinite loop

8. A(n) ____________________ is a counter variable that is incremented each time a particular event occurs.

10. A(n) ____________________-controlled loop is an event-controlled loop whose event is the attempt to read past the end of an input file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer 2: 1 2 3 4 5
as n is starting from 1 to <=5

Answer 3:D
if beta crosses 10 or comes down below 0 than it will terminate

Answer 4:
initiliazation
Answer 5:True
Answer 6: matrix operations,searching and sorting
Answer 7: 40
as it adds 25+10+6
also it adds -1 later loop break

Answer 8:iteration counter
Answer 10:event

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
2. What is the output of the following code fragment? n = 1; while (n <=...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT