C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
C How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
8th Edition
ISBN: 9780134227023
Author: Paul J. Deitel; Harvey Deitel
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 8, Problem 8.11E

(Random Sentences) Write a program that uses random-number generation to create sentences. The program should use four arrays of pointers to char called article, noun, verb and preposition. The program should create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. AS each word is picked, it should be concatenated to the previous words in an array large enough to hold the entire sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. The program should generate 20 such sentences. The arrays should be filled as follows: The article array should contain the articles “the”, “a”, “one”, “some” and “any”; the noun array should contain the nouns “boy”, “girl”, “dog”, “town” and “car”; the verb array should contain the verbs “drove”, “jumped”, “ran”, “walked” and “skipped”; the preposition array should contain the prepositions “to”, “from”, “over”, “under” and “on”.

After the preceding program is written and working, modify it to produce a short story consisting of several of these sentences. (How about the possibility of a random term-paper writer?)

Blurred answer
Students have asked these similar questions
Indicate true or false for the following statements: Every element in an array has the same type. The array size is fixed after it is declared. The array size declarator must be a constant expression. The array elements are initialized when an array is declared.
C++ c++ write a hangman game that randomly generates a word and prompts the user to guess one letter at a time, as shown in the sample run. Each letter in the word is displayed as asterisk. when the user makes a correct guess, the actual letter is then displayed. When the user finishes a word, display the number of misses and ask the user whether to continue to play with another word. Declare an array to store word as follow: Store 20 different words in a text file, read them into an array. Randomly pick a number 1..20 and use this word for the current round.
Part 1: Randomizing an Array In this problem you will write a program that will randomize the elements of an array created by the user. 1. Prompt the user to enter an integer, then asks the user to enter that many values. Store these values in an array and print the array. Then re-shuffle the array elements so randomly. Do not just randomize the order in which they are printed; actually change the way they are stored in the array. Do not create a second array; just rearrange the elements within the array you have. (Hint: Swap elements that need to change places.) When the elements have been randomized, print the array again. 2. Create another version of your program that applies the following modification to the randomization process: elements that have been already swapped should not be swapped again. Example: if element 1 was swapped with element 10, when the 10 th element is reached it should not be swapped again. Yet if the 2 nd element is reached it can be swapped with the 10o the…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License