ADVERTISEMENT
ADVERTISEMENT

Ruby program to demonstrate the escape sequence characters

Ruby Example: Write a program to demonstrate the escape sequence characters.
Submitted by Nidhi, on December 31, 2021

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!



ADVERTISEMENT

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.