Make an array called array with three elements in it, a hashmap /dict / associative array called hash with three elements in it, and a string variable called str with at least 15 characters where one of those characters is duplicated twice (i.e., in the string at least 3 times). hint: declare -a array #creates an index array & declare -A hash #creates an associative array Use echo to print both your arrays (both ‘array’ and ‘hash’) as strings on a single line. (Use loops) Save just a portion of your indexed array to a new array variable. Write a loop to print out each item of the new array on a line by itself. Remove the last element from your indexed array. Remove the first element from your index array. Use echo to print out your indexed array on a single line. Use an if statement to do this: If your array contains 2, print “true” otherwise print “false” Create a read-only string variable and demonstrate that it cannot be changed. Echo a substring of str which does not contain the first or last characters of str. Echo the last bit of str that does not contain the thrice-repeated character from step 1. Echo every part of str after the first instance of the thrice-repeated character. Write an expression that echoes the value of an unset variable, but have the parameter expansion replace the unset variable’s value with any value you want and assign the variable to this value. Echo the now-set variable from 13.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter6: Using Arrays
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

 

  1. Make an array called array with three elements in it, a hashmap /dict / associative array called hash with three elements in it, and a string variable called str with at least 15 characters where one of those characters is duplicated twice (i.e., in the string at least 3 times).

    hint: declare -a array #creates an index array & declare -A hash #creates an associative array

  2. Use echo to print both your arrays (both ‘array’ and ‘hash’) as strings on a single line. (Use loops)

  3. Save just a portion of your indexed array to a new array variable.

  4. Write a loop to print out each item of the new array on a line by itself.

  5. Remove the last element from your indexed array.

  6. Remove the first element from your index array.

  7. Use echo to print out your indexed array on a single line.

  8. Use an if statement to do this: If your array contains 2, print “true” otherwise print “false”

  9. Create a read-only string variable and demonstrate that it cannot be changed.

  10. Echo a substring of str which does not contain the first or last characters of str.

  11. Echo the last bit of str that does not contain the thrice-repeated character from step 1.

  12. Echo every part of str after the first instance of the thrice-repeated character.

  13. Write an expression that echoes the value of an unset variable, but have the parameter expansion replace the unset variable’s value with any value you want and assign the variable to this value.

  14. Echo the now-set variable from 13.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,