Q:

Ruby program to demonstrate the escape sequence characters

belongs to collection: Ruby Strings Programs

0

In this program, we will demonstrate an escape sequence character with string 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 demonstrate escape sequence characters is given below. The given program is compiled and executed successfully.

# Ruby program to demonstrate the 
# escape sequence characters

puts "Hello\tworld"
puts "Hello\b\b\b world"
puts "Hello\rworld"
puts "1:Hello\n2:World"

Output:

Hello   world
He world
world
1:Hello
2:World

Explanation:

In the above program, we used the following escape sequence characters and printed strings:.

  • \t: tab space
  • \b: back space
  • \r: carriage return
  • \n: newline

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 demonstrate the string concatenati... >>
<< Ruby program to demonstrate the example to write d...