Question

Given the existence of two-dimensional array double A[M][N], where M and N are #defined as the...

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.

Homework Answers

Answer #1

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;
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Define a function named sumsin that accepts double precision variable theta, double precision variable alpha, and...
Define a function named sumsin that accepts double precision variable theta, double precision variable alpha, and unsigned integer n, and returns the solution of ∑ k = 0 n sin ⁡ ( θ + k α ) as a double precision value using an iterative structure (i.e. a loop). Note the symbol for theta is θ, and the symbol for alpha is α. Only show the function definition. Do not write an entire program with a main function. Just write...
C++ program for : 1. Given an array of real numbers and the dimension n (n...
C++ program for : 1. Given an array of real numbers and the dimension n (n is entered from the keyboard). B form an array, each element bi - arithmetic mean of the array elements and excluding ai. 2. Given an array of integers dimension n. Change the array so that all the elements of the module which is not equal to the maximum element of the array, replaced by zero, and equal - unit. 3. Given an array of...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i];...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i]; } return (double)sum/n; } Rewrite the function to eliminate the array subscripting (a[i]), using pointer arithmatic instead. Write a program that reads a line of input and checks if it is a palindrome (ignoring spaces) Write a program that takes the name of a file as a command line argument, and prints the contents of the file (similar to the linux 'cat' program). Write...
In C programming language write a function that takes two arrays as input m and n...
In C programming language write a function that takes two arrays as input m and n as well as their sizes: size_m and size_n, respectively. Then it checks for each element in m, whether it exists in n. The function should update a third array c such that for each element in m: the corresponding position/index in c should be either 1, if this element exists in m, or 0, if the element does not exist in n
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Matlab Queatoin: The test suite generates a random M x N matrix with a random number...
Matlab Queatoin: The test suite generates a random M x N matrix with a random number of rows and columns that is assigned to the variable A . The element values of the matrix are random double precision numbers that fall in the range from -10 to 10. The matrix has between 5 and 10 rows and between 5 and 10 columns. Assuming A is defined in the workspace, write a script with commands to perform the operations described below...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
Recall that if A is an m × n matrix and B is a p ×...
Recall that if A is an m × n matrix and B is a p × q matrix, then the product C = AB is defined if and only if n = p, in which case C is an m × q matrix. (a) Write a function M-file that takes as input two matrices A and B, and as output produces the product by columns of the two matrix. For instance, if A is 3 × 4 and B is...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT