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.
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!
Select
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?
Nagarro Associate Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits