part 1: part 2: NOTE: you are writing a code frament to call the function and ou
ID: 3545050 • Letter: P
Question
part 1:
part 2:
NOTE: you are writing a code frament to call the function and output the first and last elements; do not write a complete program. And you do not need to define the function, assume it is there and just call it. You should probably review the previous problem to see how the function was defined so that you pass the correct parameters --- pass the array, the number of rows, and the number of columns.
part 3:
part 4:
NOTE: you are writing a code frament to call the function and output the value that is returned; do not write a complete program. And you do not need to define the function, assume it is there and just call it. You should probably review the previous problem to see how the function was defined so that you pass the correct parameters --- pass the array, the number of rows, and the number of columns.
part 5:
part 6:
Explanation / Answer
//part 1 starts here
void matrixAdd1(double M[MAXROWS][MAXCOLS],int numRows, int numCols){
int i,j;
for(i=0;i<numRows;i++){
for(j=0;j<numCols;j++){
M[i][j] += 1.0;
}
}
}
//part 1 ends here
//part 2 starts here
matrixAdd1(data,N,N);
cout<<data[0][0]<<","<<data[N-1][N-1];
//part 2 ends here
//part 3 starts here
double matrixAdd1(double M[MAXROWS][MAXCOLS],int numRows, int numCols){
int i,j;
double max = M[0][0];
for(i=0;i<numRows;i++){
for(j=0;j<numCols;j++){
if(M[i][j] > max){
max = M[i][j];
}
}
}
return max;
}
//part 3 ends here
//part 4 starts here
double max = matrixMax(data,N,N);
cout<<max;
//part 4 ends here
//part 5 starts here
bool isIthRowExactlyZero(int i,double M[MAXROWS][MAXCOLS],int numRows, int numCols){
int j;
for(j=0;j<numCols;j++){
if(M[i-1][j] != 0){
return false;
}
}
return true;
}
//part 5 ends here
//part 6 starts here
bool flag = isIthRowExactlyZero(3,data,numRows,numCols);
if(flag == true) cout<<"YES";
else cout<<"NO";
//part 6 ends here
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.