Given a string name, we have to find the initials of the name
Examples:
Input : prabhat kumar singh
Output : P K S
We take the first letter of all
words and print in capital letter.
Input : Jude Law
Output : J L
Input : abhishek kumar singh
Output : A K S
The complexity of this code will be less than O(w) where w is number of words in sentence, which can be little better than number of characters in String. This code is contributed by Anuj Khasgiwala We can also use strtok() function in C/C++ to achieve this.
This article is contributed by Prabhat kumar singh. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy