What are the values stored in the array a after the following code executes?
int[] a = new int[10];
a[0] = 1;
for (int i = 1; i < a.length; i++)
a[i] = 2 * a[i - 1] - 1;
What are the values stored in the array a after the following code executes? int[] a...
5. (2 points) What are the values in array x after the following code executes (list all of the elements of the array)? CS1113 Introduction to Computer Science Page 2 of 2 double []x 2,-3,4,-5,6,-7 for(int i-1; i < x.length; ++i)
Draw a picture of array A, showing the values stored in it after execution of each code segment below. Use the following data: 0 1 2 3 4 5 6 7 8 9 int A[4][2]: int k, m: for (int i = 0: i < = 3: i++) for (int j = 0: j < = 1: j++) A[i][j] = 0: for (int j = 1: j < = 10: j++) { cin > > k: switch (k) { case...
What will be the value of w after the following section of code executes: int w = 4, 9 = 3; if (a < 5) if (w == 7) W = 3; else W = 3; else if (w > 3) W = 2; else W = 1; Select one 2.3 0 b.o 0.2 d. 1
Which of the following are valid array declarations? a. int[] array- new int[10]; b. double [array double[10]; c. charl charArray "Computer Science"; None of the above Analyze the following code: class Test public static void main(Stringl] args) System.out.println(xMethod(10); public static int xMethod(int n) System.out.println("int"); return n; public static long xMethod(long n) System.out.,println("long"); return n The program displays int followed by 10 The program displays long followed by 10. The program does not compile. None of the above. tions 3-4 are...
Question 15 After the following code executes, what is the output if user enters 0? int x =-1; cout << "Enter O or 1:"; cin >> X; if (x) cout << true else cout << false O nothing will be displayed true O false 0
What is the value of result after the following code executes? int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
What elements does the array numbers contain after the following code is executec int[] numbers = new int [8]; numbers [1] = 3; numbers [4] = 99; numbers [7] = 2; int x = numbers[1]; numbers(x) = 44; numbers (numbers [7]] = 11; O 13, 11, 44, 99, 2] O 10, 3, 11, 44, 99, 0, 0, 2] O 13, 0, 11, 44, 99, 0, 21 O 10, 3, 2, 44, 99, 0, 0, 11]
Given a bubble sort and the following array: [10,7,19,5,16] What are the values after the first iteration? Given an insertion sort and the following array: [50,5,35,70,6] What does the array look like after the first insertion: Fill in the missing code for InsertionSort method // Insertion Sort method //sorts an array of Auto objects public static void insertionSort(Auto [] arr) { Auto temp; int j; for (int i=1; i<arr.length; i++) { j=i; temp=arr[i]; while (j!=0 &&(temp.getModel().compareTo(arr[[j-1].getModel())<0)...
Array manipulation (a) Write Java code for a method exchange (int [] a, int i, int j) that exchanges the values stored at indices i and j in the array a. You do not need to worry about cases where either i or j is an invalid index. Give the best estimate you can for its time complexity (b) In an ordered array of n items, how can we determine whether or not an item belongs to the list using...