Question: What is printed by the following program segment? int loopVar; for (loopVar = 0; loopVar < 6; loopVar++) { if (loopVar < 3) cout <

What is printed by the following program segment?

int loopVar;

for (loopVar = 0; loopVar < 6; loopVar++)

{

if (loopVar < 3)

cout << '*';

else

cout << '%';

}

2.

A function checkFactor accepts two integer parameters. It returns true if the second parameter is a factor of the first (that is, the second number multiplied by some other number is equal to the first number. In other words, the second parameter divides the first evenly), and false otherwise.

Write the function prototype, definition (header and body), and a sample call from the main program. You do not have to write the entire main program.

A function listFactors accepts one integer parameter. It prints out all factors of the parameter (that is all integers that divide the parameter with no remainder). For example, if the parameter is equal 6, the function prints out:

1, 2, 3, 6

Write the function prototype, definition (header and body), and a sample call from the main program. You do not have to write the entire main program.

4. Two Dimensional Arrays:

A. Given the following array: int twice[3][2];

Write the C++ code that sets all elements of the array to zero.

B. Show a drawn picture of the array filled in after the following code executes.

for (i = 0; i < 3; i++)

for (j = 0; j < 2; j++)

twice[i][j] = i + j +

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!