Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

When I enter I came, I saw, I conquered! , i get comma's included in the output. How do I remove the commas? Also, please

When I enter I came, I saw, I conquered! , i get comma's included in the output. How do I remove the commas?

Also, please comment on lines to try to explain the code to me because I am trying to understand the teachers code. Thank you! I will make sure to thumbs up the answer

the code:

#include #include

int main()

{

char string[256], text[256], words[100][256], temp[256];

int i=0, j=0, k=0, n=0, count;

/* Read the input from the user */

printf("Enter your input string:"); fgets(string, 256, stdin); string[strlen(string) - 1] = '\0';

/*extracting each and every string and copying to a different place */ while (string[i] != '\0')

{ if (string[i] == ' ')

{ words[j][k] = '\0'; k = 0; j++; }

else

{ words[j][k++] = string[i]; } i++; }

words[j][k] = '\0'; n = j;

/* sort the words in the given string */

for (i = 0; i

{ strcpy(temp, words[i]); for (j = i + 1; j

{ if (strcmp(words[i], words[j]) > 0)

{ strcpy(temp, words[j]); strcpy(words[j], words[i]); strcpy(words[i], temp); } } //inner for } //outer for

printf("Frequency of words: "); i = 0;

/* find the frequency of each word and print the results */ while (i

/* count - indicates the frequecy of word[i] */ printf("%s\t%d ", words[i], count);

/* skipping to the next word to process */ i = i + count; }//while

printf(" "); return 0; }

Output is supposed to look like this:

image text in transcribed

Output Came SaW conquered

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

6. Be able to choose and prepare a training site.

Answered: 1 week ago