Given the existence of two-dimensional array double A[M][N], where M and N are #defined as the number of rows and columns, respectively, define a function named sqabsmax that accepts array A as an argument (i.e. input parameter) and returns the square of the maximum absolute value element in A. Use the const qualifier if appropriate. Only show the function definition. Do not write an entire program with a main function. Just write the definition for function sqabsmax.
Please find below code for the function sqabsmax to find the square of maximum absolute value.
Don't forget to give a Like.
Code:
#include <iostream>
#include <cmath>
using namespace std;
void sqabsmax(double array1[][3],int row,int col){
double maximum;
for(int i=0;i<row;i++){
maximum=abs(array1[i][0]);
for(int j=1;j<col;j++){
if(abs(array1[i][j])>maximum){
maximum=abs(array1[i][j]);
}
}
}
maximum=maximum*maximum;
cout<<"square of maximum absolute value
is:"<<maximum;
}
Output: square of maximum absolute value is: 3025
int main()
{ int ro=3,co=3;
double array1[3][3]={
{1,2,3},
{-45,30,50},
{-55,20,1}};
sqabsmax(array1,ro,co);
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.