Posts

Showing posts with the label find common words in two sentences

Common Words ISC Computer Science 2021 Practical

Write a program to accept a paragraph containing two sentences only. The sentences may be terminated by either '.', '?' or '!' only. Any other character may be ignored. The words are to be separated by a single blank space and must be in uppercase. Perform the following tasks: (a) Check for the validity of the accepted paragraph for the number of sentences and for the terminating character. (b) Separate the two sentences from the paragraph and find the common words in the two sentences with their frequency of occurrence in the paragraph. (c) Display both the sentences separately along with the common words and their frequency, in the format given below. Test your program for the following data and some random data: Example 1 : INPUT: IS IT RAINING? YOU MAY GET WET IF IT IS RAINING. OUTPUT: IS IT RAINING? YOU MAY GET WET IF IT IS RAINING. COMMON WORDS FREQUENCY IS 2 IT 2 RAINING 2 Example 2 : INPUT: INDIA IS MY MOTHERLAND AND I AM PROUD OF MY MOTH...