Given a string name. we have to find the initial of the name
Input : tech code bit Output : T C B We take the first letter of all words and print in capital letter. Input : Tech Code Output : T C Input : tech code bit Output : T B C
1) Print first character in capital.
2) Traverse rest of the string and print every character after space in capital letter.
// C++ program to print initials of a name
(name.length() == 0)
// Since touuper() returns int, we do typecasting
cout << (
// Traverse rest of the string and print the
// characters after spaces.
i=1; i<name.length()-1; i++)
// Driver code
string name =
"tech code bit"
T C B
We can also use strtok() function in C/C++ to achieve this.
Disclaimer: This does not belong to TechCodeBit, its an article taken from the below
source and credits.
source and credits:http://www.geeksforgeeks.org/program-find-initials-name/
We have built the accelerating growth-oriented website for budding engineers and aspiring job holders of technology companies such as Google, Facebook, and Amazon
If you would like to study our free courses you can join us at
http://www.techcodebit.com. #techcodebit #google #microsoft #facebook #interview portal #jobplacements