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 integer T denoting the number of test cases.
For each test case, there is a single line containing the string STR.

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.
Be the first one to answer
Add answer anonymously...
Nagarro Associate Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter