Home »
Ruby Tutorial »
Ruby Programs
Ruby program to convert a string into uppercase
Last Updated : December 15, 2025
Problem Solution
In this program, we will create a string and convert the string into uppercase using the upcase() method and print the updated string.
Program/Source Code
The source code to convert a string into Uppercase.is given below. The given program is compiled and executed successfully.
# Ruby program to convert a
# string into Uppercase
str = "Hello";
uStr = str.upcase();
print "Uppercase string: ",uStr;
Output
Uppercase string: HELLO
Explanation
In the above program, we created a string str initialized with "Hello". Then we used the upcase() method to convert the string into uppercase and return the updated string. After that, we print an updated string.
Ruby Strings Programs »
Advertisement
Advertisement