do the following task in bash/shell scripting WEEK 5 Task: Sort integer Array in ascending order. Find shortest value in integer array. Make shell function which can find out that input number is prime or not
Q: If an array XARR is initialised as 'int XARR[] = {1,2,3};' in which array location is the last…
A: XARR[] = {1,2,3} In the above array XARR there are 3 elements, Array index starts from 0 So, at…
Q: In JS Create a function that takes an array of integers as an argument and returns the same array in…
A: Input - Array Output - sorted array logic - while(arr.length>0){ min=Math.min(...arr)…
Q: Write a function named BusStatistica(), that takes as parameter a two-dimensional array named bus of…
A: As no programming language is specified, it is solved in Basic C++
Q: Which of the following best describes the array name n in the declaration int n[10];? Select one:…
A: The name of the array A is a constant pointer to the first element of the array. So A can be…
Q: js code const find a5 = n.findIndex(num => n var a = 5 * i + '\t''); console.log(finda5);…
A: the correct code for above question in javascript is given below step 2:- the code which u have…
Q: In session 21 Exercise 4, you have created a program to sort data struct mhs saved in array of…
A: In session 21 Exercise 4, you have created a program to sort data struct mhs saved in array of…
Q: When using the Quick sort on the following array Complete the index of the following. pivot: Low:…
A: I am calculating this using median of 3 quick sort: here left=low and right=high
Q: se the defined function to compute the term “nCr” for the following scenario: The values of ‘n’ and…
A: Summary :-We got the output.
Q: What will be the array S, after execution of the following statement? S DB 3,2 DUP (0,2),9,2…
A:
Q: Which of the following function declarations is correct? int computeAvg(int[][] grades, int…
A: As per our guidelines, we are supposed to answer only the 1st question when there are multiple…
Q: Which of the following codes would return a True result? (A) TRUE FALSE B) "user"== "user" False >=…
A: 9. Option D is correct D. -6*14>=17-101 10. Option D is correct D. reshape 11. Option A is…
Q: Use YOUR NAME, SURNAME, and DATE as a variable in your answer. lab6 4. State which of the following…
A: E) True F) False programming the term "pass by reference" means to pass in such a way that the…
Q: Write a public VB.Net subroutine that does the following: • Declare an array of integers of size…
A: Public Sub findMax(ByRef max As Integer) Dim arr() As Integer Dim size As Integer =…
Q: Question 3 Create a function called reduce • Inputs are the starting address of an integer array and…
A: Solution for the given problem is follows according to the mentioned guidelines to creating the…
Q: Which of the following will correctly declare, construct and initialize a tow dimensional array of…
A: Here have to determine correct option for array Implementation.
Q: write a function named "get_winer" that determines who has won a game of tic-tac-toe. the function…
A: Program: Programs are used to interact with computer systems. Programs are provided with a piece of…
Q: Campground reservations, part 3: Available campsites Excellent job! This next one's a little more…
A: Here I have created a function named availableCampsites(). In this function, I have created an array…
Q: You have two arrays A and B, of size N and M, both are in sorted order [minimum to maximum]. You may…
A: code: #include<iostream>using namespace std; // Merge A[0..n1-1] and B[0..n2-1] into//…
Q: write the following function to sort three numbers in increasing order. void sort(double &num1,…
A: void sort(double &num1,double &num2,double &num3){ double a[3] = {num1,num2,num3};…
Q: In a given statement such as int assign[5] = {100, 95, 80}; what array operation is being…
A: The answers can find in the below steps.
Q: Write a shell program to demonstrate array operations using switch case. The operations are print…
A: Values in Sliced_array: [4,5,6,7,8] Array a consists of [1,2,3,4,5,6,7,8,9,10] So Sliced_array will…
Q: Help me write a program that utilizes two functions for input and output. The first function,…
A: Note: - As the programming language is not mentioned to write the program. So, I am using the C++…
Q: C lang 1. Create a function HowManyRepeats(), which for n-elemented array will count, how many…
A: Size of array in C can be determined for any array arrayName int sizeOfArray = sizeof…
Q: 12. Is the following code segment valid although the identifier "three" is not typed? let three = 3…
A: The above question is solved in step 2:-
Q: Write a sub that creates an array day of size 7 and then populates it with the days of the week…
A: I have solved your questions with screenshots of code and output for better understanding
Q: You are given a file having a number in first row representing the size of array. Create an array of…
A: #include<iostream>#include<fstream>using namespace std; int* allocate_memory(int *n){…
Q: the context of Array List which one of the following is NOT correct? a. Array List is a good option…
A: Dear Student, When too many insertions and deletions are required , linked list is the best to use…
Q: In session 21 Exercise 4, you have created a program to sort data struct mhs saved in array of…
A: The question is to write the code for the given program. As no language has been mentioned here C…
Q: MG 13 (write a function that uses built-in functions, find and isempty) My Write a function that…
A: Procedure Followed: Start function find_Vals_Indx(A,VALUE). Assign VALS vector with all values…
Q: 1. You have an array of 4 ints which is sorted from lowest to highest. You also have a function…
A: The bubble sort works by comparing each item in the list with the item next to it, and swapping them…
Q: Which campsites are available to reserve? We want to be able to quickly find which campsites are…
A: Here I have created a function named availableCampsites(). In this function, I have created an array…
Q: Assume function call below will replace the comment in the main(). What should be the actual…
A: Actual parameter if we want to pass the address of the last double stored in aValues:…
Q: nctions that implement each of the following sorting algorithms. Please use the function prototypes…
A: As per rule, allowed to answer first question and post the remaining in the next submission. The…
Q: Write a program that takes size of array as input from user. Also ask user to input values in that…
A: Note: Since you have not provided the language to write the code so I am using Java language to…
Q: Write a function named BusStatistics(), that takes as parameter a two-dimensional array named bus of…
A: #include <iostream> using namespace std;//function declarationint BusStatistics(int a[4][5]){…
Q: Please answer the below question for operating system using shell script. write a program in bash…
A: Answer :
Q: Write a function named BusStatistical(), that takes as parameter a two-dimensional array named bus…
A: Source code: #include <stdio.h> #include<iostream> using namespace std; int main() {…
Q: C lang 1. Create a function HowManyRepeats(), which for n-elemented array will count, how many…
A: Given That 1. Create a function HowManyRepeats() that return how many elements repeat in array. 2.…
Q: Hello, I need help with this homework question for my intro to c++ course. 1) Write a function…
A: so take a 2d matrix of size 3X3 and input its values from the user take a one-dimensional array or…
Q: 3. Create a script that will find the average of {-100, 97, 83, 21, -50, 20, 101, 30}. [THE USER…
A: Algorithm: Start Implement a method avg() which takes an array 'a' and size of array n as argument…
Q: In this code, assuming no errors, what does 'docs' represent? Item.collection.insert(newItems,…
A: Given code: - Item.collection.insert(newItems, function (err, docs)
Q: Q2. You are the class representative and your class advisor always requests your help to prepare the…
A: code: #Import the required packageimport numpy#Declaring array marks = []#Get the number of…
Q: Please help me with my c++ homework. My question is about this part of the code given by the…
A: Find the answer with explanation given as below :
Q: You have an array of 4 ints which is sorted from highest to lowest. You also have a function which…
A: True
Q: You are first tasked with developing a search algorithm to search for a student by their ID in an…
A: Code for ternary search using recursive search: //Searching for Student Id in the Students list.…
Q: Go to Sheet1. In cell C11 type a VLOOKUP function to find the corresponding letter grade for the…
A: Step 1:- Introduction:- Excel is a grid of row and column that is used to maintain the database in…
Q: Write a JavaScript function on the following: a.) Create a function that will compute the sum of…
A: We need to create JavaScript code for (i) sum of each individual index values (ii)merge two array…
Q: Write a function named merge that will merge two arrays of integers. The function should do the…
A: We first sort both the given arrays separately. Then we simply merge two sorted arrays. // CPP…
Q: Write a function named BusStatistics(), that takes as parameter a two-dimensional array named bus of…
A: Program Approach: Include header files. Define function bus statistics. Now define index variable I…
do the following task in bash/shell scripting
WEEK 5
Task:
- Sort integer Array in ascending order.
- Find shortest value in integer array.
- Make shell function which can find out that input number is prime or not
- Make shell function which can eliminate all odd numbers from integer array.
- Make shell function which can find the last three prime number lesser than 100.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
- Computer Science Write a shell program to demonstrate array operations using switch case. The operations are print all values of an array, print specific values of an array, print range values, get the size of an array, search and replace value, add new value to existing array, remove a value of an array, deleting Arrays, copy an array, combining arrays, and load Content of a File into an arrayCreate a file called unsorted.dat and copy (or type) the following floating point numbers into that file. 12.75 9.39 -15.25 18.34 12.65 -23.78 15.25 10.42 7.39 Now, create a program file called Time3.cpp with the following requirements. • In your main function, read the unsorted.dat file in an array. You do not know exactly how many numbers there are in the file (your program should be generic), so declare an array of sufficiently large size and use the while loop to read the numbers into the array. • Then, use a programmer-defined function to sort this array in ascending order. You cannot create a separate array for this purpose. You need to call this function and pass the array to this function from the main function. • In your main function, write the sorted array to an output file named sorted.dat.Create two dynamic arrays A and B with random numbers.a) Merge B in array A calling a function by reference.b) Delete the Prime numbers from the merged array A calling a function by pointer.c) Print the Array A in ascending order.You have to use only two Arrays A and B throughout the code. Be carefulabout memory leakage.Example:A= [20, 30, 5, 7, 19]B= [19, 10, 15, 11, 17, 25] a) After merging B in A, the merged Array A will look like-A= [20, 30, 5, 7, 19, 19, 10, 15, 11, 17, 25] b) After deleting prime numbers the merged Array would look like-A= [20, 30, 10, 15, 25] c) Finally print the merged array in ascending orderA= [10, 15, 20, 30, 25] In C++ Please
- 4) Write a shell script to sort the given numbers in the given order, i.e., either in ascending or descending order. 5) Write a shell script to demonstrate array operations using a switch case. The operations are print all values of an array, print specific values of an array, print range values, get the size of an array, search and replace the value, add new value to an existing array, remove a value of an array, deleting arrays, copy an array, and combining arrays 6) Write a shell script to find out the sum of squares of integers from m to n where m, n are input by user.1. single element of an array can be passed to the function? true or false. 2. Array can be declared as constant? true or false. 3. which of the following gives the memory address of the first element in array x? a. X b. X[0] c. X{0} d. X_0 e. X(0) 4. The index of the last element of array X whose size is S? a. S+1 b. S-1 c. 0 d.1000 e. S 5. Assume you have the following declarations const int MAX = 1000;double A[MAX];which of the following sentences is incorrect? a. The assingnment statement MAX = 1000 is mandatory. b. we can store up to 1000 values in the mandatory. c we cannot change the size of the array A during the runtime. d. all values in the array are set to ZERO's (0) e. all above sentences are correct. 6. The only difference between char array and string is that, the string ends with '\0'? true or false. 7. Index of an array can be of type integer or double, since both deals with the digits? True or False 8. Which definition describes the term Array precisely?…Consider the following array: x = [1,2,3,4,5;6,7,8,9,10;11,12,13,14,15;16,17,18,19,20] What Octave command on array x returns a row vector whose first element is the number of rows and the second element is the number of columns of array x?
- Please fix this JavaScript function so that the when calling the function with the parameters chunk([false, true, false, true], 3); the output is [[false, true, false], [true]] (subarrays)and when the parameters are chunk([undefined, null, 0, false, NaN, ""], 3); the output is [[undefined, null, 0], [false, NaN, ""]]thank you very much! function chunk(ar, sz) { var res = []; var ind = 0; // itterating through the new length of resulting array for (var i = 0; i < ar.length / sz; i++) { var t = []; // iterating through the given size for (var j = 0; j < sz; j++) { // adding elements to new 1D array t[] t.push(ar[ind]); ind++; } // push this new array into res[] res.push(t); } // return the answer return res;}Write a java labguage program to use parallel arrays to save User ID and Password. Ask the user to enter the user ID and Passwords for 3 users Save the above information in two parallel arrays (using the same index for each user) After the input is completed, ask the user to enter any user ID and then ask the password for that ID. Confirm if the User ID and password match, if not ask the passwordWrite a single line of code that will accomplish the following: declare arr to be of type "pointer to a char" allocate a dynamic array of type char with capacity 4 assign the starting address of the array to arr HINT: Use conventional spacing (one space each side of the = operator) and don't forget your semicolon.
- Create a client that produces partly sorted arrays with the following features: 95% of the data are sorted, while 5% are random values.All items that are within 10 places of their array positionSorted, with the exception of 5% of the items that were distributed at random across the array. Create and test ideas about how such input will affect how well the algorithms in this part function.write a program that reads up to 100 numbers from a file. As you read thenumbers, insert them into an array in ascending order.Specifications:1A. Write a function called addToArrayAsc.i. It should take three arguments -a. sortedArray[ ] : sorted array that should be able to hold at most 100 floats.b. numElements : the number of elements inserted so far.c. newValue : the incoming float value to be inserted into the sortedArray.ii. The addToArrayAsc function should return a count of the elements inserted so far(i.e. the current size of the array).The function header will appear as follows: OBJECTIVES 1. Read-in command line arguments2. Read a file3. Loop through an array4. Split a string5. Create an array of struct types6. Read and Write to a file int addToArrayAsc(float sortedArray[], int numElements, float newValue);Write a public VB.Net subroutine that does the following: • Declare an array of integers of size larger than 5, you can determine the size. Read values from the keyboard to fill the array. Use inputbox to do this. Find the maximum value and subtract it from all elements in the array. Return the maximum value using a reference parameter. Note that this a subroutine not a function