ADVERTISEMENT
ADVERTISEMENT

Ruby program to illustrate the creation of strings

Ruby Example: Write a program to illustrate the creation of strings.
Submitted by Nidhi, on December 30, 2021

Problem Solution:

In this program, we will illustrate the creation of string. Here, we will print strings enclosed with a single quote, double quotes, and also store string values inside the variables and print them.

Program/Source Code:

The source code to illustrate the creation of strings is given below. The given program is compiled and executed successfully.

# Ruby program to illustrate the 
# creation of strings

# Create variables to store 
# string values
MyStr1 = "Hello World";
MyStr2 = 'Hello India';

puts MyStr1;
puts MyStr2;

# Print a string enclosed in 
# single quotes
puts 'Single quote string';

# Print a string enclosed in 
# double quotes
puts "Double quote string";

Output:

Hello India
Single quote string
Double quote string

Explanation:

In the above program, we created two variables MyStr1, MyStr2 to store string values and printed them. Here, we also printed the string enclosed within the single quote and double quote.

Ruby Strings Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.