Question

Make a C program to count the number of occurrences of words from the input. For...

Make a C program to count the number of occurrences of words from the input. For example, with input "one two one three one two" your program should output:
one 3
two 2
three 1

It should work for up to 100 different words. If there are more than 100 unique words in the input, the program should still work, and count the number of appearances of the first 100 unique words. Each word should have the same maximum amount of characters allocated. Assume these are English words (not place-names) so if you know the longest word in English, you know what to set the maximum to. Also, words must start with a letter. Thus "123" would be ignored since it is not a word, but "abc123" would be counted as a word. Convert all upper-case letters to lower-case. Ignore punctuation, except for single quotes, and dashes. Thus, the input:

I said: "one's favorite, or *best-liked* coffee? (I don't know.)"

would be treated the same as

i said one's favorite or best-liked coffee i don't know

by your program.

Read the words from standard-input until there is no more to read. Then output the words and word counts to standard output. If a word is too long to fit, truncate it.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Make a C program to count the number of occurrences of words from the input. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the fil...

    CSC110 Lab 6 (ALL CODING IN JAVA) Problem: A text file contains a paragraph. You are to read the contents of the file, store the UNIQUEwords and count the occurrences of each unique word. When the file is completely read, write the words and the number of occurrences to a text file. The output should be the words in ALPHABETICAL order along with the number of times they occur and the number of syllables. Then write the following statistics to...

  • c program that counts the number of characters, words and lines from standard input until EOF....

    c program that counts the number of characters, words and lines from standard input until EOF. attached is what i Have so far but its not working ?. about shell redirection Requirements 1. Write a C program that counts the number of characters, words and lines read from standard Input until EOF Is reached. 2. Assume the Input is ASCII text of any length. 3. Every byte read from stdin counts as a character except EOF 4. Words are defined...

  • I cant get this python program to read all the unique words in a file. It...

    I cant get this python program to read all the unique words in a file. It can only read the number of the unique words in a line. import re import string from collections import Counter # opens user inputted filename ".txt" and (w+) makes new and writes def main(): textname = input("Enter the file to search: ") fh = open(textname, 'r', encoding='utf-8' ) linecount = 0 wordcount = 0 count = {} print("Sumary of the", fh) for line in...

  • write a program in C Write a program to implement the following requirement: The program will...

    write a program in C Write a program to implement the following requirement: The program will read from standard input any text up to 10, 900, characters and store each unique word (any string that does not contain any whitespace) into a node of a linked list, following the following Node struct: struct NODE { char *word; struct NODE * prev; Note that each node must store a unique word, i.e., no word is stored in more than one node....

  • All the white space among words in a text file was lost. Write a C++ program...

    All the white space among words in a text file was lost. Write a C++ program which using dynamic programming to get all of the possible original text files (i.e. with white spaces between words) and rank them in order of likelihood with the best possible runtime. You have a text file of dictionary words and the popularity class of the word (words are listed from popularity 1-100 (being most popular words), 101-200, etc) - Input is a text file...

  • Write a program that reads a sentence input from the user. The program should count the...

    Write a program that reads a sentence input from the user. The program should count the number of vowels(a,e,i,o,u) in a sentence. Use the following function to read the sentence. Should use switch statement with toupper. int read_line(char str[],int n) {    int ch, i=0;    while((ch =getchar()) != '\n')        if(1<n)            str[i++]==ch;    str[i] != '\0';    return i; } output should look like: Enter a sentence: and thats the way it is! Your sentence...

  • Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit...

    Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit 1. For Erase-ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase function is as follow: void Erase( int a[ ], int * N, int * Search-Element) The function Erase should remove all occurrences of Search-Element from the array al). Note that array a[ ] is loaded with integer numbers entered by the user through the keyboard. N...

  • In the language c using the isspace() function: Write a program to count the number of...

    In the language c using the isspace() function: Write a program to count the number of words, lines, and characters in its input. A word is any sequence of non-white-space characters. Have your program continue until end-of-file. Make sure that your program works for the case of several white space characters in a row. The character count should also include white space characters. Run your program using the following three sets of input:             1. You're traveling through ​               another...

  • c++ Exercise #2: Words Count Write a program that prompts the user to enter a sentence,...

    c++ Exercise #2: Words Count Write a program that prompts the user to enter a sentence, then counts and prints the number of words in the sentence. Assume that there is more than one space between words of the sentence. Sample input/output: Enter a sentence: This is a 123test in There are 5 words in " This is a 123test \n"

  • The program reads an unknown number of words – strings that all 20 characters or less...

    The program reads an unknown number of words – strings that all 20 characters or less in length. It simply counts the number of words read. The end of input is signaled when the user enters control-d (end-of-file). Your program prints the number of words that the user entered. ****** How do you I make it stop when control-d is entered. My code: #include <stdio.h> void main(void) { char sentence[100]; int i = 0; int count = 1; printf("Enter a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT