Define a word as a string that can only contain alphabetical characters. Given a string of multiple words, each word is separated by one or multiple spaces (‘ ‘) or tabs (‘\t’). You are asked to count the number of words and find the longest word. In C

OUTPUT

CODE
#include<stdio.h>
#include<string.h>
int main()
{
char sent[1000]; // taking user input
printf("Enter a string: ");
gets(sent);
int i = 0, top = 0, words = 0; // variables
while(sent[i]) // looping as long as string is there
{
int l = 0;
while(sent[i]) // for one word if it is valid
{
if((sent[i] >= 'a' && sent[i] <= 'z') || (sent[i]
>= 'A' && sent[i] <= 'Z'))
l++;
else
break;
i++;
}
if(sent[i] && sent[i] != ' ' && sent[i] != '\t') //
word has other characters than alphabets
{
l=0;
while(sent[i] && (sent[i] != ' ' && sent[i] !=
'\t'))
i++;
}
else // correct words
words++;
while(sent[i] && (sent[i]==' ' || sent[i] == '\t')) //
ignoring spaces and tabs
i++;
if(l > top) // if the current word is longer, updating
top = l;
}
printf("%d %d", words, top); // printing output
}
//Please up vote. Thanks!
Define a word as a string that can only contain alphabetical characters. Given a string of...
Anagram Difference We define an anagram to be a word whose characters can be rearranged to create another word. Given two strings, we want to know the minimum number of characters in either string that we must modify to make the two strings anagrams. If it's not possible to make the two strings anagrams, we consider this number to be -t For example: tea and ate are anagrams, so we would need to modity 0 characters tea and toe are...
PLEASE WRITE SIMPLE JAVA PROGRAM AND ALSO EXPLAIN THE LOGIC.
Given a string, print the first word which has its reverse word further ahead in the string. Input Format: A string of space separated words, ending with a 's'. Conditions ; Each string ends with a $ character. All characters in the string are either spaces. $ or lower case English alphabets, Output Format : In a single line pent either . The first word from the start of the...
Write a Python program to read lines of text from a file. For each word (i.e, a group of characters separated by one or more whitespace characters), keep track of how many times that word appears in the file. In the end, print out the top twenty counts and the corresponding words for each count. Print each value and the corresponding words, in alphabetical order, on one line. Print this in reverse sorted order by word count. You can assume...
Word count. A common utility on Unix/Linux systems. This program counts the number of lines, words (strings of characters separated by blanks or new lines), and characters in a file (not including blank spaces between words). Write your own version of this program. You will need to create a text file with a number of lines/sentences. The program should accept a filename (of your text file) from the user and then print three numbers: The count of lines/sentences The count...
Question 2 Write a program that will read in a line of text up to 100 characters as string, and output the number of words in the line and the number of occurrences of each letter. Define a word to be any string of letters that is delimited at each end by whitespace, a period, a comma, or the beginning or end of the line. You can assume that the input consists entirely of letters, whitespace, commas, an<d periods. When...
Let us define a word to be a maximal nonempty sequence of alphanumeric characters and underscores (i.e. matching BRE [[:alnum:]_]\{1,\}). Consider the word to name a variable (function, type, etc.) in a programming language. We say that the word is in camel case if the subwords are introduced with an upper case letter (such as MyVerySpecialVariable). The word can start with an upper case character (UpperCamelCase) or a lower case character (lowerCamelCase). For simplicity, we assume underscores are not present...
Write a program in java to read a string object consisting 300 characters or more using index input Stream reader. The program should perform following operations. The String must have proper words and all kind of characters.(Use String class methods). a, Determine the length of the string count the number of letters in the strings , count the number of numeric object d. Calculate the number of special character e. Compute the ratio of the numeric to the total f....
PA #1: Word Counter Tabulating basic document statistics is an interesting exercise that leverages your knowledge of strings, files, loops, and arrays. In this homework, you must write a C++ program that asks the user for an input and output file. For each line in the input file, write a modified line containing a line number to the output file. Additionally, calculate the number of paragraphs, lines, words, and characters. Write the summary information to the bottom of the output...
The word ?ACETIOUS is one of the only words in the English language to contain all five vowels in alphabetical order. If these nine letters are arranged randomly, what is the probability that the resulting “word” also contains the five vowels in order?
The word FACETIOUS is one of the only words in the English language to contain all five vowels in alphabetical order. If these nine letters are arranged randomly, what i:s the probability that the resulting "word" also contains the five vowels in order?