After the above code is executed the result will be:
value contains the lowest value in array1.
Explanation:
Let's consider the array1 contains following values [4, 7, 1, 3, 8]
value = array1[0] = 4
Iteration-1
for(a=1 and 1<5 is true)
array[1]<value i.e, 7<4 is false
So the control goes back to for loop
Iteration-2
a++; i.e, 1++
for(2<5 is true)
array1[2]<value i.e, 1<4 is true
So, value = array1[2] = 1
Iteration-3
2++;
for(2<5 is true)
array1[3]<value i.e, 3<1 is false
The control goes back to the for loop
Iteration-4
3++;
for(4<5 is true)
array1[4]<value i.e, 8<1 is false
The control goes back to the for loop
Iteration-5
4++;
for(5<5 is false)
So the control comes out of for loop
And the value = 1(lowest value in array1).
You can refer the executed code with it's output given in the pictures below.
Question 21 What will be the results after the following code is executed? int[] arrayi =...
The answer I've selected was incorrect. This code is in Java final int SIZE = 25; What would be the result after the following code is executed? int[] array1 = new int[SIZE]; ... // Code that will put values in arrayı int value = 0; for (int a = 0; & <= array1.length; a++) value += arrayl[a]; سیمه value contains the highest value in arrayl. value contains the lowest value in arrayl. value contains the sum of all the values...
What would be the results of the following code? Create array1 ← [33, 88, 11, 44, 99, 55] value ← array1[0] FOR each value in array1 IF(array1[i] < value) THEN value ← array1[i] ENDIF ENDFOR Question 7 options: A) Value contains the lowest value in array1. B) Value contains the highest value in array1. C) Value contains the sum of all the values in array1. D) Value contains the average of the values in array1. Question 8 (1 point) What...
Consider the following code segment: int main() cons int SIZE -20; int values [SIZE] - f0, 23, 34, -7, 110, 42,-350, 424, 25, 99, 10, 05, 50, -5, 1, 200, -350, 437, 25, 147}; // your code goes here Write a complete program to display the values from each of the following four steps All displays must be done in main. Use separate functions for each step below, passing the array to each function. 1.1) Provide the sum of the...
1. What will be the value of x after the following code is executed? int x = 10, y = 20; while (y < 100) { x += y; } A. 90 B. 110 C. 210 D. This is an infinite loop 2. If a superclass has constructor(s): A. then its subclass must initialize the superclass fields (attributes). B. then its subclass must call one of the constructors that the superclass does have. C. then its subclass does not inherit...
Question 14 (Mandatory) (1 point) Immediately after all of the following Java source code is executed, how many bytes of memory are used to store the all of the integer values in y? int[] [] y = new int[3] []; y[0] new int [2]; y[1] new int[1]; y[2] = new int[2]; none of the other answers are correct 12 64 20 00
// PLACE YOUR NAME HERE #include <iostream> using namespace std; float findAverage (int [], int); // finds average of all //grades int findHighest (int [], int); // finds highest of all //grades int findFirstFail( int[]); int main() { int grades[100]; // the array holding 100 grades. int numberOfGrades; // the number of grades read. int pos; // index to the array. float avgOfGrades; // contains the average of the grades. int highestGrade; // contains the highest grade. int inderOfFail; //...
What is the value of y after the following code is executed? int x = 20, y = 30; do { int z; z = 3 * ( y
Question 62 (Mandatory) (1 point) Immediately after all of the following Java source code is executed, how many bits of memory are used to store all of the integer values in y? int[][] y = new int[2][2]; 00 none of the other answers are correct 20 16 64
What will be the value of x after the following code is executed? int x = 5; while (x <50) { x += 5; } a) 50 b) 45 c) Infiniteloop d) 55 Given the following code segment: Scanner in = new Scanner (System.in); boolean done = false; while (!done) { int input = in.next(); if(input.equalsIgnoreCase("q")) done = false; } What will cause the loop to terminate? a) When the user enters -1 b) The loop will never terminate c)...
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;