KRHS Internet Lesson

Teacher Name:Mr. Rung                          Date of Lesson: December

Course Name: C++                    Lesson Name: Chap 8.2b

Student Name

Password


Objective
To complete the workbook exercises.


Primary Focus
Please answer the questions below.

Site Links
Course Home Page

Additional Resources

Site Links


Question #1

Suppose that for a program that you are writing, you need to validate the user’s input and repeat the prompt if the user inputs an invalid response. In this case would a while loop or a do while loop be more appropriate?


Question #2

Suppose that for a program that you are writing, you need to validate the user’s input and repeat the prompt if the user inputs an invalid response. In this case would a while loop or a do while loop be more appropriate? Justify your answer.


Question #3

How many times will the loop below iterate?

j = 0;
while (j < 50)
{
cout « “Hello \n”;
cout « “World \n”;
}


Question #4

How many times will the loop below iterate?

j = 25;
while ( j<=100 || j>=25)
(
cout <<“Temp variable =“ << j << endl;
j = j + 3;
}


Question #5

Write a while loop that will print out all the numbers between 3 and 100 that are multiples of three.


Question #6

Identify the errors in the code below.

j = 155
while (!done)
{
if (j <= 25)
done = TRUE;
j = j — 5;
};


Question #7

Write a program that will prompt the user to enter an integer. The program should square the number and print back out the squared number. Repeat this process until 0 is entered as input.