Question

In: Computer Science

Consider a 5-by-20 integer array grades: a) Write a declaration for grades. b) How many rows...

Consider a 5-by-20 integer array grades:
a) Write a declaration for grades.
b) How many rows does the array have?
c) How many columns does the array have?
d) How many elements does the array have?
e) Write the names of all elements in the first column of the array.
f) Write the name of the element in the third row and second column of the array.
g) Write a single statement to assign the value 100 to the element in the first row and second column.
h) Write a nested loop to get all the elements from the keyboard.
i) Write a nested for statement to initialize all elements to zero.
j) Write a statement that copies the values from an array double mathGrades[20]into the
elements of the first row of grades.
k) Write a series of statements that determine and print the highest value in the first row of grades.
l) Write a statement to display the elements in column 2 of the array.
m) Write a statement to calculate the average of the elements in the first row.
n) Write a series of statements that prints the array grades in a tabular format. List the
column subscripts as headings across the top and list the row subscripts at the left of
each row.

Solutions

Expert Solution

If you have any doubts, please ask in the comments, I will try to solve it as soon as possible. If you find my answer helpful, do UPVOTE.Thanks

a) int grades[5][20];

b) array has 5 rows

c) array has 20 columns

d) array has 5*20=100 elements

e) Name of Elements of first columns : grades[0][0], grades[1][0], grades[2][0], grades[3][0], grades[4][0]

f) Name of element of third row and second column - grades[2][1]

g) grades[0][1]=100;

h)

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

   for(int j=0;j<20;j++) cin>>grades[i][j];

i)

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

     for(int j=0;j<20;j++) grades[i][j]=0;

j)

for(int i=0;i<20;i++) grades[0][i]=mathGrades[i];

k)

int max=grades[0][0];  

for(int i=1;i<20;i++) if(grades[0][i]>max) max=grades[0][i];

cout<<max;

l)

for(int i=0;i<5;i++) cout<<grades[i][1]<<endl;

m)

int sum=0;  

for(int i=0;i<20;i++) sum=sum+grades[0][i];

cout<<sum/20;

n)

cout<<" ";

for(int i=0;i<20;i++) cout<<i;

for(int i=0;i<5;i++)
{
cout<<i;

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

      cout<<grades[i][j];

cout<<endl;
}

Related Solutions

In C++ Declare an integer array of size 20 and assign the array with 20 randomly...
In C++ Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100]. Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program. Finally, print out the shuffled array. (25 points) #include<iostream> using namespace std; const int NUM = 20; int main() {      ...
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that...
Please answer these The following array is declared: int grades[20]; a. Write a printf() statement that can be used to display values of the first, third, and seventh elements of the array. b. Write a scanf() statement that can be used to enter values into the first, third, and seventh elements of the array. c. Write a for loop that can be used to enter values for the complete array. d. Write a for loop that can be used to...
declare an integer array of n numbers //enter a value for n before the declaration enter...
declare an integer array of n numbers //enter a value for n before the declaration enter values for the declared array, pass the array to the method that has the name "countNumbers" let the function countNumber count how many elements of the array in the interval [70 90] means between 70 and 90 inclusive, returns this count to the main, and prints it using format printing. --------------- Please Solve As soon as Solve quickly I get you thumbs up directly...
Declare an integer array of size 20 and assign the array with 20 randomly generated integers...
Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100]. Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program. Finally, print out the shuffled array. (25 points) #include<iostream> using namespace std; const int NUM = 20; int main() {             //...
Write in main • setArray() – This method has two integer parameters, one for the rows...
Write in main • setArray() – This method has two integer parameters, one for the rows of a two-dimensional array and the other for the columns of a two-dimensional array. The method will return a two-dimensional array of integers with rows and columns given by the parameters. In addition, the method will use the Random class, along with the nextInt() method, to give each element of the two-dimensional array a value between 1 and 20. • display() – This is...
write a function declaration for a 2d array where each row size is 8 and the...
write a function declaration for a 2d array where each row size is 8 and the function does not return anything.
Write a declaration to store the following values in an array rates : 12.9, 28.6, 11.4,...
Write a declaration to store the following values in an array rates : 12.9, 28.6, 11.4, 13.7, 9.5, 15.2, and 17.6. Include the declaration in a program that displays the values in the array by using pointer offset notation
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. IN C Program.
Write a function declaration for a function that sums each row of a 2D array, where...
Write a function declaration for a function that sums each row of a 2D array, where each row size is 10. The function does not return a result. Need it in 10 minutes, please.
Write a program that read an array consists of 4 rows and 4 columns, then computes...
Write a program that read an array consists of 4 rows and 4 columns, then computes and print the sum of the elements above and below the main diagonal. (WITH C++)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT