C Program to Find the Shortest Word in a String

A word is a consecutive non-whitespace character set. The C program here will find out the shortest word in a given string. If multiple words are present with the same length of the shortest one, it will print the first one. This program takes a string as input. The first ‘for‘ loop traverses all the … Continue reading “C Program to Find the Shortest Word in a String”

C Program to Find the Longest Word in a String

A word is a consecutive non-whitespace character set. The C program here will find out the longest word in a given string. If multiple words are present with the same length of the longest one, it will print the first one. This program takes a string as input. The first ‘for‘ loop traverses all the … Continue reading “C Program to Find the Longest Word in a String”

C Program to Replace All Occurrences of a Character by Another One in a String

Here we’ll see how to replace all occurrences of a character by another one in a string. Read also: C program to remove all occurrences of a character. This program first takes a string as input, then two characters. First character will be replaced by the second one. The replace_char() function replaces the find character … Continue reading “C Program to Replace All Occurrences of a Character by Another One in a String”

C Program to Remove all Occurences of a Character from a String

Here we’ll see how to remove all occurences of a character from a string. For example, if we remove the character ‘o‘ from the string “The quick brown fox jumps over the lazy dog“, the result will be “The quick brwn fx jumps ver the lazy dg“. All four occurneces of ‘o’ removed from the … Continue reading “C Program to Remove all Occurences of a Character from a String”

C Program to Count Words in a String

For our purpose, a word is a set of consecutive characters without any white-space. For example, ‘qnaplus‘ is a word but ‘qna plus‘ has two words. Here we’ll see how to write C program to count the number of words in a string. We can think of a simple solution of counting the white spaces … Continue reading “C Program to Count Words in a String”

0
0
0
5
0
0