a: 7
b: 13
c: 10
d: Error: Array index out of bound
e: 10
f: 21
g: 22
h: 4
i: 10
j: 1
k: [7, 15, 13, 10]
l. [7, 15, 13, 10]
m. [7, 15, 13, 10, 0, 0] (Length changed to 6)

1· (1 point each) Given the array defined below, evaluate each of the expressions and write...
Aim To improve the algorithm provided in Snippet 2.3 by reducing the number of passes. public void sortImprovement1(int[] numbers) { for (int i = 1; i < numbers.length; i++) { for (int j = 0; j < numbers.length - i; j++) { if (numbers[j] > numbers[j + 1]) { swap(numbers, j, j + 1); } } } } Snippet 2.3: Bubble sort improvement 1 Change the bubble sort method so that it stops sorting if the array is untouched after...
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
Problem: Write a program that generates random numbers between 1 and 10 and fill an array of size 20 with them. Have your program sort the array then output in order the number of occurrences of each random number generated. Use the STL sort function to sort your array. How to use the STL sort: #include <algorithm> ... int a[20] ... sort(a,a+20); Example Output: This program generates random numbers and tabulates the results Original List Sorted: a[ 0] 1 a[...
Given an array of integers as declared below, write C loop to fill it up (assign, store) with the numbers 1-100 column by column, i.e. a[0][0] = 1; a[1][0] = 2;... Use only the variables below as printed do not write them again. Just write the two loops. int a [10][10]; int value = 1; int r,c;
Write a JAVA program with methods that initializes an array with 20 random integers between 1 and 50 and then prints four lines of output, containing 1)The initialized array. 2)Every element at an even index. 3)Every even element. 4)All elements in reverse order. Requirements (and hints): 1. Build a method that takes any integer array as input and prints the elements of the array. ALL printing in this lab must be done using a call to the printArray method and...
You have an array that is defined as int array2[4] = {50, 100, 150, 200}; write a for loop and a while loop to print each element of the array with a label in the following manner using printf() with the correct format string. array2[0] = 50 array2[1] = 100 array2[2] = 150 array2[3] = 200 can it be written in C
IN C++ Write a function numberOfOddNumbers that takes an array of integers and its size (length) as parameters and then returns the number of the odd numbers found in the array. For example, if an array called list stores the following values: int list []= { 1,1, 8,6,9,4,3,9595,0 }; Then the call of numberOfOddNumbers (list,9) should return 5. If instead, the list had stored these values: int list2[] = { 2, 4, 6, 8, 10, 208 }; Then the call...
***Please complete the code in
C***
Write a program testArray.c to initialize an array by getting user's input. Then it prints out the minimum, maximum and average of this array. The framework of testArrav.c has been given like below Sample output: Enter 6 numbers: 11 12 4 90 1-1 Min:-1 Max:90 Average:19.50 #include<stdio.h> // Write the declaration of function processArray int main) I int arrI6]i int min-0,max-0 double avg=0; * Write the statements to get user's input and initialize the...
In the blank below, write the contents of array arr after the following code is executed up to the comment indicated in the main procedure below? #include <iostream> #include <algorithm> using namespace std; void do something(int list[], const int size); int main() { const int SIZE(10); int arr[SIZE] = { 5, 8, 1, 7, 3, 9, 4, 6, 10, 2 }; do somethingCarr, SIZE); ** Write the contents of array arr in the space below when execution reaches here. */...
These are questions pertaining to Java.
Incorrect Question 1 0/1 pts Evaluate the below expression. Perform a step-by-step evaluation to clearly understand how a computer would evaluate the expression. You will need to solve these questions manually in the exam, without being able to evaluate these expressions using a Java program, so please learn this and indicate the answer. (40/3 +974) 30 Incorrect Question 2 0/2 pts Evaluate the below expression. Perform a step-by-step evaluation to clearly understand how a...