Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 15, Problem 5E
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that writes 100 integers created randomly into a file. Integers are separatedby a space in the file. Read the data back from the file and display the sorted data. Yourprogram should prompt the user to enter a file- name. If the file already exists, do not overrideit.
You are required to implement a program which will read in a text file (.txt)
containing words which are arranged in sentences.
Your program should first ask the user for the name of the file and then count
the number of individual words and characters (including numbers and
punctuation) in the file. The word and character count result should be printed
on the screen.
Furthermore, your program should count the number of individual words
starting with the letter 'A', 'B', 'C' and so on to 'Z'. Again, these statistics should
be printed on the screen.
Your program should display the letter that appears at the start of most words.
The program must be written in C.
You should illustrate the operation of your program by generating a text file
containing 3 sentences from a lead news story on the day of testing.
Create a program that reads three lines from a text file. Each line should be read one at a time. For each word on a line, the user should be asked to specify how many syllables are in that word. The program should then inform the user if the file contains a valid Hiku using the function below:
def isHiku (firstLine, secondLine, thirdLine):if (firstLine == 5 and secondLine == 7 and thirdLine == 5):
return True return False
print("The file contains a Hiku:", isHiku(5,7,5))Note: You must replace the values in the function with the numbers counted by your program.
Chapter 15 Solutions
Programming in C
Ch. 15 - Type in and run the three programs presented in...Ch. 15 - Prob. 2ECh. 15 - Write a program to copy one file to another,...Ch. 15 - Write a program that merges lines alternately from...Ch. 15 - Write a program that writes columns m through n of...Ch. 15 - Write a program that displays the contents of a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Design a For loop that calculates the total of the following series of numbers: 130+229+328+...+301
Starting Out with Programming Logic and Design (4th Edition)
Derive a class RegularPay from PayCalculator, as described in the previous exercise. It should have a construct...
Java: An Introduction to Problem Solving and Programming (7th Edition)
Assuming the following enum declaration exists: enum Dog { POODLE, BOXER, TERRIER } what will the following sta...
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Can enumerators be used in a loop to step through the elements of an array? Why or why not?
Starting out with Visual C# (4th Edition)
Describe the purpose of the access key attribute and how it supports accessibility.
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Fill in the blanks in each of the following statements: The arithmetic operators with the same precedence as mu...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Knowledge Booster
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
- Program reads paragraph(s) from the file and stores in a string. Then program counts the occurrence of each word in the paragraph(s) and stores all words with their number of occurrences. If that word has appeared more than one time in whole string, it should store the word only once along its total number occurrences. The output described in above (int part 3) must be stored in a new file.arrow_forwardThe program takes a single argument as the name of the file to be read. A sample file is named (Movies.txt). The program reads this file which has labeled columns separated by commas. Every row of this text file includes information about a movie. You are asked to read every row as a string and decompose the given information (separated by commas). If a costumer wants too see "List of the Genres" (or genre,score,year) all genres type must be show. I need this answer in C language. Please explain nicely. Thanks.arrow_forwardThis is Python Program 5: Improve the file copy program from Lab 9 so that it will make sure the user enters a file that exists. If a file doesn’t exist, the open function will raise the FileNotFoundError. You do not need to check if the destination exists since a file doesn’t need to exist to write it. Instead of copying the content of the source as exact, it only copies non-empty lines and it also prepend each line with a line number. A line is empty if the length of the line stripped of white space from both end is 0. The code segment below shows how to strip white space and getting the length of the string. If the length of the line is zero, the line is a blank line. line1 = " " line2 = " aa " print(len(line1.strip())) # 0 print(len(line2.strip())) # 2 In the sample run, “add.py” is the source file and “add-copy.py” is the destination file. Note that “add-copy.py” contains only non-blank lines from “add.py” and each line in “add-copy.py” is labelled with a line number. Sample run:…arrow_forward
- Please do this in Python: Write a program that allows the user to navigate lines of text in a file. The program should prompt the user for a filename, read the file and input the lines of text into a list. The program then enters a loop in which it prints the number of lines in the file and prompts the user for a line number. Actual line number range from 1 to the number of lines in the file. If the input is 0, the program quits. Otherwise, the program prints the text associated with that number.arrow_forwardTry reading the contents of animals.txt and from there create a file named animals sorted.txt that is sorted alphabetically.The following code listing is the body of the animals.txt file.arrow_forwardA file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a file. The program should output the unique words and their frequencies in alphabetical order. Variations are to track sequences of two words and their frequencies, or n words and their frequencies.arrow_forward
- In Python IDLE Write a program that reads the file’s contents and determines the following: The number of uppercase letters in the file The number of lowercase letters in the file The number of digits in the file The number of whitespace characters in the file Then the program should do a mass replacement of all spaces with a ‘-‘, and then replace any uppercase letters with lowercase letters. After the replacement of the spaces, the count of letters, digits, and spaces should be rerun, the number of replacements indicated, and a second report of letters, digits and spaces should be printed. Save the results of the changes in a file named “testoutput.txt”. This file must be submitted as part of the submission for your lab. Output should look like this: Uppercase letters: 20 Lowercase letters: 310 Digits: 4 Spaces: 82 >>> Hint: This program does not need to use any lists – the entire file can be read into one string. Problem 2. Date Printer - Write a program…arrow_forwardProgram that reads a string from the user and append it into a file.arrow_forwardQuestion 3: Write a program that reads a file of text and displays the number of words in that file. The filename is entered by the user. A Word is defined to be any number of consecutive letters (a...z, A...Z) only. Words are separated from each other by spaces (* “) and/or commas (*,') and/or semicolon (*;') and/or full stop (':'). Your program should write the words in the file "output.txt" along with the total word count. As shown below. file.txt Abedef, ;; gfdyire hsdhfkdsf, , ; , dkjfkjdljkfldj. .. mnbsdT .. ;; nbmxhs , a djks. output.txt Abcdef gfdyire hsdhfkdsf dkjfkjdljkfldj mnbsdT nbmxhs a djks Total count of words are = 8arrow_forward
- 7. Write a program that will randomly generate 1000 uppercase letters. Write those alphabets in a text filenamed “in.txt”. Now Sort (in ascending order) all the alphabets in the file “in.txt” using insertion sort. Useseparate function for REPLACEMENT_SORT. Show the sorted output in your console window.arrow_forwardThe function print_last_line in python takes one parameter, fname, the name of a text file. The function should open the file for reading, read the lines of the file until it reaches the end, print out the last line in the file, report the number of lines contained in the file, and close the file. Hint: Use a for loop to iterate over the lines and accumulate the count. For example: Test Result print_last_line("wordlist1.txt") maudlin The file has 5 lines.arrow_forwardCreate a program that asks the user for the name of a file and then rearranges the contents of the file so that its lines are in alphabetical order. Use the STL algorithm sort.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License