write a program to accept a sentence containing two sentences only. the sentence may be terminated by either "." "?" or "!". any other character may be ignored. the word may be separated by only one single blank and to be in upper case. separate the paragraph in two sentences find common words and frequency of common words with any example
Answers
In c language, I wrote this program,
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hey!");
printf("How are you?");
printf ("okay bye.");
getch();
}
Answer:
const text = document.querySelector('input[type=text]');
function count_duplicate(a){
let counts = {}
for(let i =0; i < a.length; i++){
if (counts[a[i]]){
counts[a[i]] += 1
} else {
counts[a[i]] = 1
}
}
for (let prop in counts){
if (counts[prop] >= 2){
console.log("'" + prop + "'" + " counted: " + counts[prop] + " times.")
}
}
}
function findDuplicates() {
textcontent = text.value;
fullstop = '.';
textcontentarray = textcontent.toLowerCase().replaceAll('.', '').split(' ');
console.log(count_duplicate(textcontentarray));
}
You'll have to check js console and use html input text, but this should work. Have a nice day!