×

Ruby Tutorial

Ruby Basics

Ruby Control Statements

Ruby Methods

Ruby Classes and Methods

Ruby Arrays

Ruby Sets

Ruby Strings

Ruby Classes & Objects

Ruby Hash

Ruby Tools

Ruby Functions

Ruby Built-in Functions

Misc.

Ruby Programs

Ruby program to demonstrate the escape sequence characters

Last Updated : December 15, 2025

Problem Solution

In this program, we will demonstrate an escape sequence character with string and print them.

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

Ruby Strings Programs »


Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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