Exercise 1-11. How would you test the word count program? What kinds of input are most
likely to uncover bugs if there are any?
Exercise 1-12. Write a program that prints its input one word per line.

help me wid these questions temme the source code and the logic and the meaning of these questions....

thnx..

Recommended Answers

All 4 Replies

Exercise 1-11. How would you test the word count program? What kinds of input are most
likely to uncover bugs if there are any?
Exercise 1-12. Write a program that prints its input one word per line.

help me wid these questions temme the source code and the logic and the meaning of these questions....

thnx..

1) Have your program read in text from a file, where the word count of an editor, could be used to easily check your program's accuracy.

2) Show me your attempt at 1-12. How would you do it be hand, if you were tasked with that job?

1-11: imagine you have a program that counts the number of words that it takes as input.

how does the program take any group of characters and determine where the words begin and end? by the existence of "whitespace" separating each word, right? Remember, whitespace can be a space ' ', a tab '\t', or a newline '\n'.... So basically the program looks at each character in the input string and when it finds whitespace, it counts the preceding group of characters as a word

(a) if you had a program that performed this function, how would you verify it? how would you show that the program did indeed count the correct number of words given some input.

(b) and in this program, what could be a likely source for an error to occur? is there some event that could, say, cause a miscount? again, think of how words are counted. by the separation of words between the whitespace (space, tabs, newlines). For instance, is there a case where you could have some whitespace in the middle of a word, but it should only count as one word and not two? Or conversely, can there be a case where two words are not separated by whitespace, but they should be counted as two words and not one?

1-12: write a program to do the following:

(a) accept a string of text input
(b) separates each word in that string so that it prints one word per line

how to do this part (b)? you would have to look for the whitespace right? just start by looking for spaces ' ', and get that to work correctly. print the characters until you find a space, then print a newline. continue til the end of the string.


.

Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.


help ME WID THIS .........

Exercise 1-9. Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank.


help ME WID THIS .........

What's wrong with `with'? It only takes one more character than `WID' to type, ... but then, you don't care about typing unnecessary characters since you went generous with `.........'.

I am going to help you.
How would you make a program that removes the extra spaces of this literal string?

"     This     is      a  silly   and malformed       string   "
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.