Problem Data Base Your program must read in a file containing sentences with pun
ID: 3540706 • Letter: P
Question
Problem Data Base
Your program must read in a file containing sentences with punctuation. It will parse the sentences into words and punctuation. The words will be entered into a dictionary and the punctuation into a list. Case is ignored when adding words to the dictionary. Remember a dictionary is kept in lexicographic order. Each entry in the dictionary and list will have a count of the number of times the word or punctuation appears in the original text. After reading the text (a line with a first character of $ terminates the text), print out the dictionary and list with the counts. Your program will next read a line formatted like this: worldExplanation / Answer
#include <stdio.h> #include <string.h> #include<conio.h> void main() { char text[100],word[10],rpwrd[10],str[10][10]; int i=0,j=0,k=0,w,p; clrscr(); printf("PLEASE WRITE ANY TEXT. "); printf("GIVE ONLY ONE SPACE AFTER EVERY WORD "); printf("WHEN COMPLETE PRESS Ctrl-Z "); gets(text); printf(" ENTER WHICH WORD IS TO BE REPLACED "); scanf("%s",word); printf(" ENTER BY WHICH WORD THE %s IS TO BE REPLACED ",word); scanf("%s",rpwrd); p=strlen(text); for (k=0; k<p; k++) { if (text[k]!=' ') { str[i][j] = text[k]; j++; } else { str[i][j]=''; j=0; i++; } } str[i][j]=''; w=i; for (i=0; i<=w; i++) { if(strcmp(str[i],word)==0) strcpy(str[i],rpwrd); printf("%s ",str[i]); } getch(); }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.