Exercise 13.5 Write a Bash script that contains two numeric arrays, array1 and array2, initialized to the values in the sets {1, 2, 3, 4, 5} and {1, 4, 9, 16, 25}, respectively. The script should produce and display an array whose elements are the sum of the corresponding elements in the two arrays. Thus, the first element of the resultant array is 1 + 1 = 2, the second is 2 + 4 = 6, and so on.
#!/bin/bash
# Arr1 create an array
arr1=(1 2 3 4 5)
# Arr2 create an array
arr2=(2 4 6 8 10)
# create an empty result array
res=()
# ${!arr1[@]} will provide a array of indices. We will walk through
them.
for i in ${!arr1[@]}
do
# Add the elements in arr1 and arr2 at index i.
sum=$(( ${arr1[$i]} + ${arr2[$i]} ))
# Add element to the result array
res+=( $sum )
done
# Display the arrays and the result array
echo ${arr1[@]}
echo ${arr2[@]}
echo ${res[@]}


Exercise 13.5 Write a Bash script that contains two numeric arrays, array1 and array2, initialized to...
Recreate the one hundred element arrays of sin and cos you
created in Exercise 3.10. Print these arrays out to a file in the
form of a table. The first line of the table should contain the first
element of both arrays, the second line the second element, an so
on. Keep the file as we will use it later.
Exercise 3.10:
My solution to 3.10:
import math
from numpy import zeros
array1 = zeros(100, float)
for x in range(100):...
Write a C program that inputs 5 elements into each of 2 integer arrays. Add corresponding array elements, that array1 [0] + array2[0], etc. Save the sum into a third array called sumArray[]. Display the sum array. Submit your and the input and output of the complete execution.
i need help writing these programs in c++ format
1. Enter two integer arrays: array1-129, 0, -56, 4, -7 and array2-19, 12, -36, -2, 12 3. Write the code to form and display another array array3 in which each element is the sum of numbers in the position in both arrays. Use pointers and functions: get array0. process arrays0 and show array0 (50 points) 2. Enter a positive 5-digit integer via the keyboard. Display each digit and fol- lowed by...
This is for JAVA programming. Create a test class that contains two arrays and two methods: - The first array has 3 rows and 3 columns and is initialized with type double data - The second array has 4 rows and 4 columns and is also initialized with type double data - The first method ArraysRows will receive an array of type double as an argument and then print out the sum and average of all elements in each ROW....
using matlab
In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1. Determine the sum of all...
Can someone solve number 5 using Matlab?
In Class Exercises 8-Arrays For the following exercises, assume an array is already populated, your job is to write a program that traverses the array. DO NOT HARD CODE the last index. In other words, you code for 1-4&6 should be able to handle the following 2 arrays: amp2 10 array1 [52, 63, 99, 71, 3.1] array2 - [99:-3: 45); For 5: wordArray1 wordArray2 ('number, 'arrays', 'indices', 'hello', finish' [number, 'different, 'finish? 1....
Please answer all the questions
2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...
c++ please help Create two arrays of 20 elements, called myArray1 and myArray2 Create a function randBetween that returns an integer between 2 integer inputs (int randBetween(int min, int max)); Fill the myArray1 with the random values. Loop thru the myArray1 and find the difference between the element i and element i + 1; put that difference in array2 example: array1 = {1, 3, 4, 5} array2 ends up having {-2, -1, -1} Loop thru myArray1 and find the min...
Programming in java
In this part of this Lab exercise, you will need to create a new class named ArrayShiftMult. This class carries out simple manipulation of an array. Then you should add a main method to this class to check that your code does what it is supposed to do. 1. Create a BlueJ project named LAB06 as follows: a. Open the P drive and create a folder named Blue), if it does not exist already. Under this folder,...
Q1) How would you declare an array of doubles called myDoubles? Arrays can be initialized in one of two ways. In one method, the array elements are placed in a list enclosed in curly braces after the array name definition. For example, the code below creates an array of ints with 3 elements: 1, 2 and 3. int[] a = {1, 2, 3, 4}; We can also initialize an array with a new construct, indicating how many elements we want...