Given a string, the task is to print the first and last character of each word in a string.
Input: Geeks for geeks Output: Gs fr gs Input: Computer applications Output: Cr as
- Run a loop from the first letter to the last letter.
- Print the first and last letter of the string.
- If there is a space in the string then print the character that lies just before space and just after space.
Below is the implementation of the above approach.
Gs fr Gs
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Print last character of each word in a string
- Capitalize the first and last character of each word in a string
- Remove the first and last character of each word in a string
- Reverse every word of the string except the first and the last character
- Print the string after the specified character has occurred given no. of times
- Print the string by ignoring alternate occurrences of any character
- Print Kth character in sorted concatenated substrings of a string
- Find a string such that every character is lexicographically greater than its immediate next character
- Replace every character of string by character whose ASCII value is K times more than it
- Modify the string such that every character gets replaced with the next character in the keyboard
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Map every character of one string to another such that all occurrences are mapped to the same character
- Replace all occurrences of character X with character Y in given string
- Print list items containing all characters of a given word
- Print longest palindrome word in a sentence
- Most frequent word in first String which is not present in second String
- String containing first letter of every word in a given string with spaces
- Print each word in a sentence with their corresponding average of ASCII values
- Replace every character of a string by a different character
- Recursively print all sentences that can be formed from list of word lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.