Ruby program to convert a string into uppercase

Ruby Example: Write a program to convert a string into uppercase.
Submitted by Nidhi, on January 02, 2022

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 »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.