/*THIS IS A C++ CODE FOR THE GIVEN QUESTION ... EVERYTHING IN BOLD
IS PART OF COMMENT AND IS WRITTEN FOR EXPLANATION AND IS NOT A PART OF WORKING OF THE CODE
A SCREEN SHOT OF OUTPUT IS ATTACHED */
#include <iostream>
#include <cstdlib>
#include <ctime>
/*THE ABOVE TWO LIBRARIES ARE INCLUDED TO ACCESS A PREDEFINED FUNCTIOLN CALLED
RAND() THAT PRODUCES RANDOM NUMBERS*/
using namespace std;
int main()
{
int size = 10;
/* size VARIABLE DEFINES THE LENGTH OF THE ARRAY*/
int x[size], y[size];
for (int i = 0; i < size; i++)
/*THIS IS A FOR LOOP THAT RUNS FROM 0 TO SIZE-1 THAT IS ITERATES THE ARRAY*/
{
x[i] = rand() % 100;
/*RAND FUNCTION GENERATES RANDOM NUMBERS IN AN UNDEFINED RANGE
TO MAKE ITS RANGE LIMITED TO 100 WE PERFORM A MODULO 100 OPERATION
FOR EXAMPLE : IF WE HAVE A NUMBER 3902 WHEN WE DO 3902%100 IT SHOULD GIVE
= 39
THEREFORE FOR EVERY INTEGER GENERATED WE GET A NUMBER IN OUR SPECIFIED RANGE*/
cout << x[i] << " ";
/*TO PRINT THE RANDOM NUMBERS GENERATED*/
}
cout << endl;
for (int i = 0; i < size; i++)
{
y[i] = i * x[i];
/* i IS THE INDEX AT WHICH THE RESPECTIVE VALUE IS STORED IN THE ARRAY
ACCORDING TO THE QUESTION WE HAVE ITERATED Y AND SAVED THE VALUES OF X MULTIPLIED
BY ITS RESPECTIVE INDEX*/
cout << y[i] << " ";
/*THIS STATEMENT IS USED TO DISPLAY NEW VALUES IN Y*/
}
}
Problem 1: Consider 2 integer arrays, x and y, of the same size (assume size =...
Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be: from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array...
For the following C statement, what is the corresponding MIPS assembly code? Assume the arrays hold 16-bit integer values, $ s0 is the base for array X, $ s1 is the base for array Y, and $ t0 and $ t1 are index variables i and j respectively. Comment code X [j] = Y [i + j];
Write a program that reads two integer arrays each of size 10 then find and print the inner product of the arrays. Inner product can be performed by multiplying each element of one vector by the corresponding element in the second vector that has the same index, and summing all the products. For example: A[5]= {1,2,3,4,5} B[5]= {2,0,3,1,5} Inner product = 40
Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...
The method generate() will produce integer arrays of a random size between 10 and 20 members. The method print() will print out the members of an integer array input. The method insert() will accept two arrays as inputs. It will produce a new array long enough to contain both arrays, and both input arrays should be inserted into the new array in the following manner: select a random member of the first array, and insert every member of the second...
C++ Programming 1. Write a function (header and body) that accepts an integer as an argument and returns that number squared. 2. Write the code that will fill an integer array named multiples with 10 integers from 5 to 50 that are multiples of five. (This should NOT be in the form of an initialization statement.) 3. Write the code that will display the contents of the integer array named multiples. Recall: the size of the array is 10. 4....
Suppose v is an array with 100 int elements. If 100 is assigned to v[100], what happens? Show the code. An array of 1000 integers is declared. What is the largest integer that can be used as an index to the array? Shows the code. Consider the declaration: int v[1]; What is the index of the last element of this array? Declare an array named a of 10 int elements and initialize the elements (starting with the first) to the...
Please write a JAVA program according to following requirement. Thanks Part 2 -Arrays We can use the Math.random method to generate random integers. For example, Math.random () generates a random integer greater than or equal to 0 and less than 1. The expression Math. random) 6generates random numbers between 0 and 5, simulating the throw of a die. In this lab assignment, you will use an array to test whether the random generator is fair; that is, whether each possible...
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....