Q:

Ruby program to illustrate the creation of strings

belongs to collection: Ruby Strings Programs

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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 MyStr1MyStr2 to store string values and printed them. Here, we also printed the string enclosed within the single quote and double quote.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Ruby Strings Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Ruby program to illustrate the difference between ... >>