Which of the following would be the best example of a counter-controlled loop?
A. Print a number backward.
B. Validate data read from the keyboard.
C. Print a calendar.
D. Print the sum of the digits in an integer.
Answer: C
You might also like to view...
Write the names of three commonly used software lifecycles.
What will be an ideal response?
Write a program that will read a message from another text file and surround each occurrence of an abbreviation with <> brackets. Write the marked message to a new text file. For example, if the message to be scanned is How are u today? Iirc, this is your first free day. Hope you are having fun! :) the new text file should contain How are today?
<:)> Text messaging is a popular means of communication. Many abbreviations are in common use but are not appropriate for formal communication. Suppose the abbreviations are stored, one to a line, in a text file named abbreviations.txt. For example, the file might contain these lines: lol :) iirc 4 u ttfn The solution for this project makes use of a couple methods that break out the processing of a line. The major method processes and marks a line for a single abbreviation. It finds the index of the abbreviation in the line and then breaks the line up into 3 parts. It then gets the character immediately before and after the abbreviation and checks to see if either is a letter or digit. If so, then we assume that the abbreviation is part of a legal word and don’t mark it. Otherwise, we splice in the <> marker. This is done in a while loop that processes the remaining part of the line until the abbreviation is not found.
Correct the faults in the isLeapYear() and getNumDaysInMonth() methods of Figure 11-12 and generate test cases using the path testing methods. Are the test cases you found different than those of Table 11-14 and Figure 11-13? Why? Would the test cases you found uncover the faults you corrected?
What will be an ideal response?
A segment of logically related code is called a(n)
a) program b) structure c) algorithm d) module