With Complete Solutions
// 5.1 point A, B, C true, false, sometimes true, sometimes false?
int count = 0;
while ( count < 100)
{
cout << "Point A: " << count << endl;
cout << "Welcome to C++\n";
count++;
cout << "Point B: " << count << endl;
}
cout << "Point C: " << count << endl; Correct Answers a =
always true;
b = sometimes true;
c = always false;
// 5.11 what are the tree parts of a for loop control? Correct
Answers -initial action
-loop-continuation-condition
-action-after-each-iteration
// 5.12 suppose the input is 2 3 4 5 0. what is the output of the
following code?
int number, sum = 0, count;
for (count = 0; count < 5; count++)
{
cin >> number;
sum += number;
}
, cout << "sum is " << sum << endl;
cout << "count is " << count << endl; Correct Answers sum is
14
count is 5
// 5.19 identify and fix the errors in the following code
for ( int i = 0; i < 10; i++);
sum += i;
if(i < j);
cout << i << endl;
else
cout << j << endl;
while (j < 10);
j++;
do
{
j++;
} while ( j < 10) Correct Answers -sum undeclared
-j undeclared
- if statement not inside for loop
-semi-colon at end of for & if statement and while statement
-missing semicolon at end of do-while loop
// 5.21 how many times is the print statement executed?
for ( int i = 0; i < 10; i++)
for(int j = 0; j < i; j++)
cout << i*j << endl; Correct Answers 24 times
0
7
14
21