Convert First Letter to Upper Case
Given a string STR
, transform the first letter of each word in the string to uppercase.
Example:
Input:
STR = "I am a student of the third year"
Output:
"I Am A Student Of The Third Year"
Explanation:
The output string has each word's initial letter capitalized.
Constraints:
1 ≤ T ≤ 10
1 ≤ |STR| ≤ 105
, where |STR| denotes the length of the string.- The string contains only spaces and alphabetic characters (both uppercase and lowercase).
Note:
Words in the string are separated by spaces.
Input:
The first line of input contains an integerT
denoting the number of test cases.
For each test case, there is a single line containing the stringSTR
.
Output:
For each test case, print the transformed string with each word's first letter in uppercase. Each test case's output should be on a new line.
Note:
You don’t need to handle input/output in your function. Just implement the provided function.
AnswerBot
2d
The function takes a string as input and transforms the first letter of each word to uppercase.
Split the input string into individual words using spaces as delimiters.
For each word, convert the first ...read more
Help your peers!
Add answer anonymously...
Top Nagarro Associate Engineer interview questions & answers
Popular interview questions of Associate Engineer
Top HR questions asked in Nagarro Associate Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app