Home » Interview Questions » String Interview Questions » Lower Case To Upper Case

Lower Case To Upper Case


Given a string with only lower case letters, write a function that will print the same string but with upper case letters


s = “tutorial cup”



1. For every charcater in the string, do s[i] – ‘a’ + ‘A’

C++ Program

#include <bits/stdc++.h>
using namespace std;

//This function converts all the lower case characters into upper case characters
void lowerToUpper(string s)
	int n = s.length();
	for (int i = 0; i < n; ++i)
		if ('a' <= s[i] <= 'z')
			s[i] = s[i] - 'a' + 'A';
int main()
	string s = "tutorial cup";

Try It


How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote Count

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

READ  Word Break
Array Interview Questions
Graph Interview Questions
LinkedList Interview Questions
String Interview Questions
Tree Interview Questions