Given the string, the task is to capitalise the first and last character of each word in a string.
Input: Geeks for geeks Output: GeekS FoR GeekS Input: Geeksforgeeks is best Output: GeeksforgeekS IS BesT
- Create a character array of the String
- Run a loop from the first letter to the last letter.
- Check if the character is the starting or end of the word
- Check if the character is a small letter.
- If yes, then Capitalise the character of the string.
Below is the implementation of the above approach.
Geeks for Geeks GeekS FoR GeekS
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 the first and last character of each word in a String
- Remove the first and last character of each word in a string
- Print last character of each word in a string
- Reverse every word of the string except the first and the last character
- Modify string by increasing each character by its distance from the end of the word
- Get the first letter of each word in a string using regex in Java
- Remove the first and last occurrence of a given Character from a String
- How to find the first and last character of a string in Java
- Remove first and last character of a string in Java
- Swap the first and last character of a string in Java
- Minimum operation require to make first and last character same
- String containing first letter of every word in a given string with spaces
- Most frequent word in first String which is not present in second String
- C program to find and replace a word in a File by another given word
- Queries to find the last non-repeating character in the sub-string of a given string
- Length Of Last Word in a String
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Longest Common Prefix using Word by Word Matching
- C program to Replace a word in a text by another given word
- Find the word from a given sentence having given word as prefix
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.