Question

In: Computer Science

Given the declaration                         char table[7][9];              &nb

  1. Given the declaration

           

            char table[7][9];

           

                which of the following stores the character 'B' into the fifth row and second column of the array?

            A) table[5] = 'B';

            B)   table[2][5] = 'B';

            C)   table[5][2] = 'B';

            D) table[1][4] = 'B';

            E)   table[4][1] = 'B';

  1. This program fragment is intended to zero out a two-dimensional array:

int arr[10][20];

            int i, j;

           

            for (i = 0; i < 10; i++)

                  for (j = 0; j < 20; j++)

                      // Statement is missing here

           

                What is the missing statement?

            A) arr[j+1][i+1] = 0;

            B)   arr[i-1][j-1] = 0;

            C)   arr[i+1][j+1] = 0;

            D) arr[i][j] = 0;

            E)   arr[j][i] = 0;

3. Given this nested For loops

  for (i = 0; i < M; i++)

                  for (j = 0; j < N; j++)

                      cout << arr[i][j];

           

                what is the appropriate declaration for arr?

            A) int arr[M+N];

            B)   int arr[M+1][N+1];

            C)   int arr[M][N];

            D) int arr[N][M];

            E)   int arr[N+1][M+1];

  1. Given the declarations

           

            float alpha[5][50];

            float sum = 0.0;

           

                which one computes the sum of the elements in row 2 of alpha?

            A) for (i = 0; i < 50; i++)

                           sum = sum + alpha[2][i];

            B)   for (i = 0; i < 5; i++)

                           sum = sum + alpha[2][i];

            C)   for (i = 0; i < 50; i++)

                           sum = sum + alpha[i][2];

            D) for (i = 0; i < 5; i++)

                           sum = sum + alpha[i][2];

  1. Look at the following array definition.

int numberArray[9][11];

Write a statement that assigns 130 to the first column of the second row of this array.

  1. Write a statement which will assign 18 to the last column of the last row of this array.

Values is a two-dimensional array of floats that include 10 rows and 20 columns. Write a

code that sums all the elements in the array and stores the sum in the variable named total.

Solutions

Expert Solution

Ans 1: E)   table[4][1] = 'B';

The first half is used to get to the 5th row(4th index) and second part is used to get to the 2nd column(1 st index).

Ans 2: D) arr[i][j] = 0;

Since, we the row index values ranges from 0 to 9 and the column index value ranges from 0 to 19.

Ans 3: C)   int arr[M][N];

Since, we the row index values ranges from 0 to M-1 and the column index value ranges from 0 to N-1.

Ans 4: The options to this question are incorrect. Since, we need to access the second row (i.e., 1st index considering arrays are 0 index by default). The correct answer is

for (i = 0; i < 50; i++)

                           sum = sum + alpha[1][i];

Ans 5:

Write a statement that assigns 130 to the first column of the second row of this array:

=> numberArray[1][0] = 130;

Write a statement which will assign 18 to the last column of the last row of this array.

=> numberArray[8][10] = 18;

Ans 6:

float numarray[10][20];
float total = 0;
for (int i=0; i<10; i++){
    for (int j= 0; j<20; j++){
        total += numarray[i][j];
    }
}

Related Solutions

Question 1. Given the following table answer the questions.                           Score Respondent   &nb
Question 1. Given the following table answer the questions.                           Score Respondent          X            Y         x-x       (x-x) 2         y-y      ( y-y) 2     ( x-x) ( y-y) A. Rose                 18          92    B. Bush                 36          65     C. Novicevic         24          91 D. Vitell                28          85                                                                        E. Walker              25          70     a. Calculate Pearson’s Product Movement Correlation Coefficient (r). Show your work. b. Based on the correlation coefficient which you calculated, in two words how would you describe the relationship between the two variables in the “test”? Question 2. PHR Score                Score Respondent        X             Y         x-x       (x-x) 2         y-y      ( y-y) 2     ( x-x) ( y-y) A....
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1;...
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1; char ch2; int main() { cin.get(ch1); cin.get(ch2);    cout << ch1 << chConst << ch2;    return 0; }
Based on this code: CREATE TABLE DEPARTMENT ( DepartmentName Char(35) NOT NULL, BudgetCode Char(30) NOT NULL,...
Based on this code: CREATE TABLE DEPARTMENT ( DepartmentName Char(35) NOT NULL, BudgetCode Char(30) NOT NULL, OfficeNumber Char(15) Not Null, DepartmentPhone Char(12) NOT NULL, CONSTRAINT DEPARTMENT_PK primary key(DepartmentName) ); CREATE TABLE EMPLOYEE( EmployeeNumber Int NOT NULL AUTO_INCREMENT, FirstName Char(25) NOT NULL, LastName Char(25) NOT NULL, Department Char(35) NOT NULL DEFAULT 'Human Resources', Position Char(35) NULL, Supervisor Int NULL, OfficePhone Char(12) NULL, EmailAddress VarChar(100) NOT NULL UNIQUE, CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeNumber), CONSTRAINT EMP_DEPART_FK FOREIGN KEY(Department) REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE, CONSTRAINT...
Table: x: 6, 2, 15, 9, 12, 5, 8 y: 8, 9, 4, 7, 6, 9,...
Table: x: 6, 2, 15, 9, 12, 5, 8 y: 8, 9, 4, 7, 6, 9, 8 1) Make the scatter diagram. 2) Find the equation of the regression line using the formulas given in class. They must appear the intermediate steps of substitutions. Round the answers to three decimal places. 3) Find the correlation coefficient using the formulas given in class. Steps should appear intermediates of substitutions. Round the answer to three decimal places. 4) Find the value predicted...
9.            Deflation:                A.can result in an increase in employment.        &nb
9.            Deflation:                A.can result in an increase in employment.                B.raises the cost of making purchases.                C.is caused by changes in interest rates. C is Wrong                D. encourages people to hold cash rather than invest. 15.         Which of the following causes an outflow of funds from a domestic economy?                A.household savings                B.government transfer payments B is Wrong                C.imports                D.government tax collections 12.         In the factor markets:                A.households supply resources.               ...
QUESTION 1 Pearson’s Product-Moment Correlation Coefficient 1. Given the following table answer the questions.                        &nb
QUESTION 1 Pearson’s Product-Moment Correlation Coefficient 1. Given the following table answer the questions.                           Score Respondent          X            Y         x-x       (x-x) 2         y-y      ( y-y) 2     ( x-x) ( y-y) A. Rose                 18          92    B. Bush                 36          65     C. Novicevic         24          91 D. Vitell               28          85                                                                        E. Walker              25          70                                                                                         a. Calculate Pearson’s Product Movement Correlation Coefficient (r). (2 points) b. Based on the correlation coefficient which you calculated, in two words how would you describe the relationship between the two variables in the “test”? (2 points) 2. PHR Score                           Score Respondent       X             Y         x-x       (x-x) 2         y-y      (...
QUESTION 1 Pearson’s Product-Moment Correlation Coefficient 1. Given the following table answer the questions.                        &nb
QUESTION 1 Pearson’s Product-Moment Correlation Coefficient 1. Given the following table answer the questions.                           Score Respondent          X            Y         x-x       (x-x) 2         y-y      ( y-y) 2     ( x-x) ( y-y) A. Rose                 18          92    B. Bush                 36          65     C. Novicevic         24          91 D. Vitell               28          85                                                                        E. Walker              25          70 a. Calculate Pearson’s Product Movement Correlation Coefficient (r). (2 points) b. Based on the correlation coefficient which you calculated, in two words how would you describe the relationship between the two variables in the “test”? (2 points) 2. PHR Score                           Score Respondent       X             Y         x-x       (x-x) 2         y-y      ( y-y)...
The data is given as follow. xi 2   6 9 13 20 yi 7 18 9...
The data is given as follow. xi 2   6 9 13 20 yi 7 18 9 26 23 The estimated regression equation for these data is  = 7.6 + .9x. Compute SSE, SST, and SSR (to 1 decimal). SSE SST SSR What percentage of the total sum of squares can be accounted for by the estimated regression equation (to 1 decimal)? % What is the value of the sample correlation coefficient (to 3 decimals)?
Use the given Strings.c and Strings.h module: Strings.c: #include "Strings.h" #include <string.h> #include<stdlib.h> #include<stdio.h> char* substring(char*...
Use the given Strings.c and Strings.h module: Strings.c: #include "Strings.h" #include <string.h> #include<stdlib.h> #include<stdio.h> char* substring(char* str, int iPos){ if(iPos > strlen(str)||iPos < 0)return (char*)NULL; char* substr; substr = &str[iPos]; return substr; } int charPosition(char* str, char c){ char* string = (char*)malloc(strlen(str)+1); int i; for(i = 0; i < strlen(str)+1; i++) { if(str[i] == c) { return i; } } return -1; } Strings.h: #include <string.h> /* substring - return a pointer to the substring beginning at the iPos-th position....
Tables: Create table Item(    &nbs... Bookmark Tables: Create table Item(                 ItemId           &nb
Tables: Create table Item(    &nbs... Bookmark Tables: Create table Item(                 ItemId                 char(5) constraint itmid_unique primary key,                 Decription           varchar2(30),                 Unitcost               number(7,2)); Create table Customer(                 custID                   char(5) constraint cid.unique primary key,                 custName          varchar2(20),                 address                                varchar2(50)); Create table Orderdata( orderID                char(5) constraint oid_uniq primary key,                 orderdate           date,                 shipdate              date,                 ItemId                  char(5) references Item.ItemId,                 No_of_items     number(4),                 Unitcost               number(7,2),                 Order_total        number(7,2),                 custID                   char(5) references customer.custID); Insert Into Item values(‘A123’,’Pencil’,2.5);...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT