Question

What type of loop, such as counter-control or sentinel-control, will you use in each of the following situations? a. Sum the following series: 1 + (2 / 1) + (3 / 2) + (4 / 3) + (5 / 4)+ ... + (10 / 9) b. Sum the following numbers, except the last number: 17, 32, 62, 48, 58, -1 c. A file contains an employee’s salary. Update the employee’s salary.

Solution

Verified
Answered 2 years ago
Answered 2 years ago
Step 1
1 of 4

a. Counter-Controlled Loop

In such situations, we can use a counter-controlled while loop. Because it uses a counter to control the loop. In a counter-controlled while loop, we must initialize the counter before the loop, and the body of the loop must contain a statement that changes the value of the counter variable.

Create an account to view solutions

Create an account to view solutions

More related questions

1/4

1/7