Write a Ruby program to create a new string which is n copies of a given string where n is a non-negative integer.
Ruby Code:
def multiple_string(str, n) return str*n end print multiple_string('a', 1),"\n" print multiple_string('a', 2),"\n" print multiple_string('a', 3),"\n" print multiple_string('a', 4),"\n" print multiple_string('a', 5),"\n"
a aa aaa aaaa aaaaa.
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Ruby Code: