Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(50 points) Write a program that reads in a line of text and computes the freque

ID: 3677028 • Letter: #

Question

(50 points) Write a program that reads in a line of text and computes the frequency of the words in the text. Assume that the input contains words separated by white spaces, comma, period, or exclamation point. Sample input/output: Input: I came, I saw, I conquered! Output: 3 came saw conquered 1) Name your program frequency.c. 2) Assume input is no longer than 1000 characters. Assume the input contains no more than 1000 words. Assume each word is no more than 50 characters 3) Store a word into a string array when it is first encountered. Create a parallel integer array to hold a count of the number of times that each particular word appears in the input. If the word appears in the input multiple time, do not add it to the string array, but make sure to increment the corresponding word frequency counter in the parallel integer array. 4) You may use any string library functions such as strtok, strcmp, and strcpy. 5) To read a line of text, use the read line function in the lecture notes.

Explanation / Answer

#include #include #include int main() { FILE * input; char buf[256]; input = fopen("./input.txt","r"); if(input == NULL) { perror("input.txt"); exit(1); } while(!feof(input)) { fscanf(input,"%s ",&buf); printf("Word: %s. ",&buf); } fclose(input); return 0; }