Problem #1: Consider the code below. Supply the MISSING statement. // Function t
ID: 3552613 • Letter: P
Question
Problem #1:
Consider the code below. Supply the MISSING statement.
// Function to display the values in array, first to last.
void Display(int X[], int numValues)
{
int k; // for-loop variable.
_____________________________ // MISSING for
{
cout << X[k];
}//for loop
}//Display
int main()
{
int Score[24]; // Test scores for students in programming course.
//-| Call Display to display the values in array Score.
} //main
Problem #2:
Write a statement to declare a 2-dimensional int array named Avg with
4 rows and 2 columns, and initialized to
4 3
1 2
3 5
8 4
Problem #3: []
Consider the declarations:
string Class[18]; // Array of 18 student names.
int k; // for-loop control variable.
ON ONE LINE, write the loop to print out the values in the Class
array in reverse order.
__________________________________________________
Problem #4: []
Consider this problem: The teacher wants to print out the scores on
a test in descending (highest to lowest score) order. There are 37
students in the class.
DIRECTIONS: Write the statement to print out the MEDIAN score, i.e.,
the middle score.
NOTE: Do not insert a new line.
int Score[37];
//-| Read in 37 scores.
...
//-| Sort Score into descending order.
//-| Print the median score.
_________________________________________________
Problem #5: []
int Z[15]; // ONE-DIMENSIONAL array of 15 cells, like a spreadsheet column.
int Q[12][8]; // TWO-DIMENSIONAL array of 12 rows and 8 columns, like a spreadsheet.
The total number of values that can be stored arrays Z and Q is ______ .
Explanation / Answer
1. for(k=0; k<numValues; k++)
2.
#include<iostream>
#define COL 2
#define ROW 4
using namespace std;
int main(){
int Avg[ROW][COL] = {{4,3},{1,2},{3,5},{8,4}};
return 0;
}
3.
for(k=17 ;k>=0; k++){ cout<<Class[k]; }
4.
cout<<"Median score "<<Score[18];
5.
total = 15+ 12*8 = 15+96 = 111
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.