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
4mo
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...
Nagarro Associate Engineer interview questions & answers
An Associate Engineer was asked 10mo agoQ. Write a program.
An Associate Engineer was asked 11mo agoQ. How do you find the largest element in an array with O(N) complexity?
An Associate Engineer was asked 11mo agoQ. How do you detect a loop in a linked list?
Popular interview questions of Associate Engineer
An Associate Engineer was asked 10mo agoQ1. Write a program.
An Associate Engineer was asked 10mo agoQ2. How do you find the largest element in an array with O(N) complexity?
An Associate Engineer was asked 10mo agoQ3. How do you detect a loop in a linked list?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

