Ruby Code Examples



Here I will provide Ruby Code Examples for all basic ruby programs of String, Array, Logical programs and Number based programs. In Ruby programming language.

Array Based Logical Programs


Ruby program to remove duplicate values in array

Program to find the second smallest number in an array in ruby

Find second largest number from an array in Ruby

Find smallest element in array without using min function in Ruby

Find largest element in array without using max function in Ruby

String Based Logical Programs

Ruby program to remove duplicate characters of a string

Ruby program to find occurrence of character in string

Find smallest and longest substring of a string in Ruby

Ruby program to reverse string without using direct method

Ruby program to convert full name into initials

Ruby program to remove common characters from two strings

Ruby program to remove vowels from string

Ruby program to search a string in a sentence

Number Based Logical Programs

Strong number program in Ruby


Prime number program in Ruby

Write a Ruby program to check the armstrong number

Ruby program for random number between two numbers

Ruby program to check Palindrome Number

Ruby program to reverse a number

Ruby program to sum of digits of a number

Ruby program to calculate generic root

Write a Ruby program to swap two arrays

- Ruby program to split number into digits

- Ruby program to print perfect numbers from 1 to 1000

- Ruby program to check perfect number