25) It will not sum the table values because the columns are not controlled
explanation :- j has declared but not initialized
26) 9
explanation:- it will sum the value of 3*3 matrix
27) the program segment is written correctly
28) sum=sum+s[ i ][ j ]
29) &cost[i]
30) 9.1
explanation;-result = y[ i+4 ] =y[4]=9.1
QUESTION 25 Examine the following program segment. Assuming the array table has values in it, what...
What are the values of the array in the given code? You can draw a table using the tool or you can write the values with their index values. double my_arr[2][3]; int i, j; for(i = 0; i < 2; I++) { for(j = 0; j<3; j++) { my_arr[i][j]=i+(j*2); } }
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...
Question 31 In C, what is the computational result of 8/5*2.5? Question 32 Examine the for statement given below. What is the most correct answer given below? for(degrees==0.0; degrees<=360.0; degrees+=20.0) ( ) Degrees must be in radians. ( ) Degrees must be capitalized. ( ) Cannot use double equal signs for assigning values to variables. ( ) Degrees cannot be incremented in the manner shown. Question 33 In a C program the formal and actual parameters that are used between...
Please change this 2 thread program to a 4 thread program. /*compile as "gcc thread.c -pthread" */ #include <pthread.h> #include <stdio.h> #include <time.h> #define SIZE 100000000 //100 M //#define SIZE 10000 #define NUMBER_OF_TIMES 100 float a[SIZE]; typedef struct { int start; int end; double sum; int pid; } range; void *thread_function(void *arg) //define a function that will be executed from //within a thread { range *incoming = (range *) arg;...
howthe output of the following 4 program segments (a) const int SIZE=8; int values[SIZE] = {10, 10, 14, 16, 6, 25, 5, 8}; int index; index=0; res = values[index]; for (int j=1; j<SIZE; j++) { if (values[j] > res) { res = values[j]; index = j; cout << index << res << endl; } } cout <<...
QUESTION 12 If an array contains unordered values, searching for a particular value O is accomplished with a linear search is accomplished with the bipolar search O can't be done in Java O requires multiple parallel processing threads QUESTION 13 What best describes the processing of the following method? public static t[] mystery (int[] list) int[] result = new int[list.length]; j 1; for (int i = 0, result.length i < list.length; i++, j--) { result[j] = list[i]; } return result;...
I must execute in C using parallel Programming techniques the following serial program: void producer_consumer(int *buffer, int size, int *vec, int n) { int i, j; long long unsigned int sum = 0; for(i=0;i<n;i++) { if(i % 2 == 0) { // PRODUCER for(j=0;j<size;j++) { buffer[j] = vec[i] + j*vec[i+1]; } } else { // CONSUMER for(j=0;j<size;j++) {...
C++ program Write a code segment to find the max element in each row and then store the values to the "result" array. For example, { {2, 7, 9, 6, 4}, => 9 {6, 1, 8, 10, 4}, => 10 {4, 3, 7, 2, 9}, => 9 {9, 9, 0, 3, 1}, => 9 {8, 8, 7, 8, 9}, => 9 {1, 2, 1, 2, 3} } => 3 the result array has the values [9, 10, 9, 9, 9,...
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...
Examine each of the following program segments carefully. Determine what is printed from each program. There are no intentional errors. 1. int array[] = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; i++) cout << array[i]*5 << “ “; Output _________________________________ 2. int *iptr; iptr = new int[5]; for (int count = 0; count < 5; count++) iptr[count] = count+1; cout << *iptr << endl; Output _________________________________ 3. int x = 50, y = 60,...