Ruby program to create an infinite loop using 'until' loop

Ruby Example: Write a program to create an infinite loop using "until" loop.
Submitted by Nidhi, on December 20, 2021

Problem Solution:

In this program, we will use the "until" loop to print the "Hello" message infinite times.

Program/Source Code:

The source code to create an infinite loop using the "until" loop is given below. The given program is compiled and executed successfully.

# Ruby program to create an infinite loop 
# using the "until" loop.

flag = false;

until flag==true
    puts "Hello";   
end

Output:

Hello
Hello
Hello
Hello
.
.

Infinite times

Explanation:

In the above program, we created a Boolean variable flag initialized with false. Then we printed the "Hello" message infinite times using the "until" loop.

Ruby Looping Programs »




Comments and Discussions!

Load comments ↻





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