Given a string which contains lowercase English alphabets. The task is to replace each consonant with the next immediate consonant that comes in English alphabets.
Let’s say we have to replace character , it will be replaced by . Another example, let’s say we have to replace character , the next immediate consonant is , hence will be replaced by .
Note: If the character is ‘z’, then look circularly in English alphabets for the next consonant, i.e. replace it with ‘b’.
Input : str = "geeksforgeeks" Output : heeltgosheelt Input : str = "gfg" Output : hgh
- Iterate the string elements from left to right.
- It the string element is consonant, then check the next immediate alphabet of this element.
- If the next immediate alphabet is a consonant, then replace it with the this alphabet. If it is a vowel, then replace the string element with 2nd immediate alphabet as there are no consecutive vowels in English alphabets.
Below is the implementation of the above program:
- Replace all consonants with nearest vowels in a string
- Program to remove consonants from a String
- Modify string by removing vowels in between two consonants
- Count consonants in a string (Iterative and recursive methods)
- Encrypt string with product of number of vowels and consonants in substring of size k
- Arrange consonants and vowels nodes in a linked list
- Count strings with consonants and vowels at alternate position
- Arrangement of words without changing the relative position of vowel and consonants
- Substrings starting with vowel and ending with consonants and vice versa
- Replace all occurrences of pi with 3.14 in a given string
- Replace a character c1 with c2 and c2 with c1 in a string S
- URLify a given string (Replace spaces is %20)
- Replace all occurrences of a string with space
- Replace all occurrences of string AB with C without using extra space
- Program to replace every space in a string with hyphen
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.