Given the following array
var myArray = [1, "two", 3, "4"]
write what the alert message will say for each of these examples:
a. alert( myArray[0] );
b. alert( myArray[0] + myArray[1] );
c. alert( myArray[2] + myArray[3] );
d. alert( myArray[2] – myArray[0] );
a. alert( myArray[0] ); Answer: 1 b. alert( myArray[0] + myArray[1] ); Answer: 1two c. alert( myArray[2] + myArray[3] ); Answer: 34 d. alert( myArray[2] – myArray[0] ); Answer: 2
Given the following array var myArray = [1, "two", 3, "4"] write what the alert message...
1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe", "pig", "beetle", "hamster", "spider", "goldfish", "cow"); A. pig B. beetle C. hamster D. spider 2. Given the following array, which statement will create a variable named product that multiplies 4 * 5, using array elements? var nums = new Array(2, 3, 4, 5, 6, 30, 40, 50, 60); A. var product = nums[1] * nums[2]; B. var product = nums[2] * nums[3]; C. var...
1.The following statement gets an element from position 4 in an array named myArray: x = myArray[4]; What is the equivalent operation using an array list named list.? A x = list.get(); B x = list.get(4); C x = list.get[4]; D x = list[4]; 2.Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>(); int data; Scanner in = new Scanner(System.in); for (int i = 0; i < 5; i++) { data = in.nextInt(); num1.add(data); if (data == 0 &&...
1. Assuming each line of information is stored in a new array, which of the following pairs are not parallel arrays? A. names of all students at Santa Fe College ID numbers of all students at Santa Fe College B. names of all students at Santa Fe College names of all students taking JavaScript at Santa Fe College C. names of all students at Santa Fe College email addresses of all students at Santa Fe College D. All three sets...
1. Implement the following: a. A template class named MyArray. 1) MyArray is a dynamic partially filled array for primitive types. 2) data members: - a pointer for the array - any associated variables needed to manage the array. 3) Constructor must insure that specified capacity is possible. Exit the program if an illegal value is specified. 4) The Big Three" are required to insure deep copy.
1) Write a public static method named printArray, that takes two arguments. The first argument is an Array of int and the second argument is a String. The method should print out a list of the values in the array, each separated by the value of the second argument. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; printArray(myArray, ", ") will print out 1, 22, 333, 400, 5005, 9 printArray(myArray,...
Question 14; Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters. (10 marks) Clue: Array myArray of size n is symmetric if myArray[0] is equal to myArray[n-1], myArray[1] is equal to myArray[n-2], and...
Given the following JavaScript code, what will be displayed on the web page? var pho = new Array(); for (var i = 0; i< 7; i++) { pho[i] = (i*i) + 3; } for (var i = 0; i< 7; i++) { document.write(i + " => " + pho[i] + "<br>"); } 1 => 4 2 => 7 3 => 12 4 => 19 5 => 28 6 => 39
#include <iostream> using namespace std; template <typename Item> class MyArray{ private: Item *myarray; int size; int used; void doubleSize(); public: MyArray(); ~MyArray(); int length(); void insertHead(Item i); void insertTail(Item i); void deleteHead(); void deleteTail(); void sortAscending(); void sortDescending(); Item operator [](int i){ return myarray[i]; } }; template <typename Item> MyArray<Item>::MyArray(){ size = 5; used = 0; myarray = new Item[size];...
Homework Question Write a void function called transformArray that takes two parameters - a reference to a pointer to a dynamically allocated array of ints, and the size of that array. The pointer is passed by referencebecause you want to change the value of the pointer. The function should dynamically allocate an array that is twice as long, filled with the values from the original array followed by each of those values times 2. For example, if the array that was...
Write a function replaceNums that replaces each element except the first and last by the larger of its two neighbors. Your function should take two parameters, an integer array and the array length (in this order). Your function should not return or print anything. Examples int myArray[2] = {1, 5); → {1.9 int myArray 1 3(1); → {1} int myArray[3] = {1, 3, 5); → {1, 5.9 int myArray[3] = {5, 3, 1); → {5, 5, 1} int myArray[5] =...