What type of iteration would be appropriate for calculating the sum of the first 100 positive integers? What type would be appropriate for calculating the sum of an arbitrary number of positive integers? Briefly describe how each of these tasks could be performed.
What will be an ideal response?
Counter-controlled iteration would be appropriate for calculating the sum of the first 100 positive integers because the number of repetitions is known in advance. The program that performs this task could use a while iteration statement with a counter variable that takes on the values 1 to 100. The program could then add the current counter value to the total variable in each repetition of the loop. Sentinel-controlled iteration would be appropriate for calculating the sum of an arbitrary number of positive integers. The program that performs this task could use a sentinel value of –1 to mark the end of data entry. The program could use a while iteration statement that totals positive integers from the user until the user enters the sentinel value.
You might also like to view...
The _____ method displays a message to the user and contains one button.
a. prompt() b. alert() c. message() d. none of the above
Which of the following is not true about navigating comments?
A) When a file is returned to you with comments, the comment icons will appear on the slides. B) You need to click each slide in the presentation and search for the icons. C) You can use the Comments group on the Review tab to move to the next comment or the previous comment. D) You can edit comments and delete comments in the Comments group.
You can jump to any specific point on the Timeline by clicking a date on the literal timeline at the ________
A) right column B) far left side of the page C) left column D) far right side of the page
To navigate from one comment to another comment, click Next or __________.
Fill in the blank(s) with the appropriate word(s).