Question
Code challenge: Arrays Complete the following code: Write a function called read_array() that reads in strings from the terminal and returns an array containing the
Code challenge: Arrays Complete the following code: Write a function called read_array() that reads in strings from the terminal and returns an array containing the strings. Use .chomp() to remove the newline from each line read. A procedure called print_array(a) that takes an array as an argument and prints out a numbered list of items in the array. Write a main() that calls read_array()then passes the returned array as an argument into a call to print_array(a) The following is an example of the output. Your code must be able to reproduce this output: Note: Your output and your function and procedure must match the name and description above exactly.
How many lines are you entering? 4 Enter text: line 1 Enter text: line 2 Enter text: line 3 Enter text: line 4 Printing lines: o line 1 1 line 2 2 line 3 3 line 4 How many lines are you entering? 4 Enter text: line 1 Enter text: line 2 Enter text: line 3 Enter text: line 4 Printing lines: o line 1 1 line 2 2 line 3 3 line 4Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started