What type of iteration would be appropriate for calculating the sum of the first 100 positive integers? What type of iteration would be appropriate for calculat- ing 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 iterations is known in advance. The application that performs this task could use a while iteration statement with a counter variable that takes on the values 1 to 100. The application could then add the current counter value to the total variable in each iteration of the loop. Sentinel-controlled iteration would be appropriate for calculating the sum of an arbitrary number of positive integers. The application that performs this task could use a sentinel value of –1 to mark the end of data entry. The application 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...
Corrective maintenance _____.
A. adds enhancements to an operational system and makes the system easier to use B. diagnoses and corrects errors in an operational system C. involves changing an operational system to make it more efficient, reliable, or maintainable D. competes for resources in an operational system
Embedded styles apply to the Hypertext Markup Language (HTML) documents in which they are created and are accessible to other documents in the website.?
Answer the following statement true (T) or false (F)
COGNITIVE ASSESSMENT Which of the following best describes the role of a UX specialist?
A. Directs and implements an organization's use of Internet and social media marketing. B. Writes and develops web content and layouts so that they will appear at the beginning of search results. C. Integrates apps and data to provide an application that manages a company's relationships with customers. D. Plans and designs software and apps that consider a user's reaction to a program and its interface.
Nontraditional data in object-oriented databases such as audio clips, video clips, pictures, and very large documents are called ________ data.
A. enterprise B. structured C. unstructured D. multidimensional