a)A.each {|array| print (array*array).to_s() +"\n" }
b)A.each_slice(4) {|array| print (array).to_s() +"\n" }
c) A.select {|array| array%4==0 }
d)A.map {|array| array*array }
e)A.inject(1) {|result,element| result*element}
Testing Code:
A = Array.new(51) {rand(20...100)} #generating 51 random number
between 20 to 100
A.each {|array| print (array*array).to_s() +"\n" } #using each
A.each_slice(4) {|array| print (array).to_s() +"\n" } #using
each slice
A.select {|array| array%4==0 } #using select
A.map {|array| array*array } #using map
A.inject(1) {|result,element| result*element} #using inject
Happy Chegging!
Write a function that takes an array A of integers as the input and does the...