Repeat these questions by writing functions

Assignment Help C/C++ Programming
Reference no: EM13163700

Q 2. A 2 dimensional array of doubles has the same number of rows and columns (a square array). Assume the values
are already loaded in the array. Write a loop to calculate the sum total of the elements of the diagonal (the elements
with the same row and column subscript values). In the following example 4x4 2-d array, the elements on the diagonal
are in boldface type. Use the partial declarations given.
12 8 -11 7
6 3 0 2.9
7 7 -11 10
-3 -7 4 8

array< array<double, 4>, 4> mat = { the initial values would go here };
double sum = 0.0;
// write the code

Page 2 of 2 2013-12-09
for (int i(0); i < 4; i++)
sum += mat[i][i];

Q 3. A 2 dimensional array of doubles has the same number of rows and columns (a square array). Assume the values
are already loaded in the array. Write a loop to calculate the sum total of the elements of the anti-diagonal (the
elements whose row and column subscripts add up to the number of rows (or number of columns as they are equal) ?
1). In the following example 4x4 2-d array, the elements on the anti-diagonal are in boldface type. Use the partial
declarations given.

12 8 -11 7
6 3 0 2.9
7 7 -11 10
-3 -7 4 8

array< array<double, 4>, 4> mat = { the initial values would go here};
double sum = 0.0;
// write the code

Q 4. Repeat these questions by writing functions that receive the arrays as constant reference parameters and return
the appropriate values through the function name (via return statement). The function header could look like:
double sumDiag(const array< array<double, 4>, 4> & mat) {
// write the code
} // end function

double sumAntiDiag(const array< array<double, 4>, 4> & mat) {
double sum = 0.0;
for (int i(0); i < 4; i++)
sum += mat[i][3 - i]; // Note: i + (3 - i) = 4 - 1
return sum;
} // end function

Reference no: EM13163700

Questions Cloud

Knowledge of future employer : Explain how knowledge of the evaluator (future employer) should influence a person’s writing of the resume or cover letter
Political-social and cultural issues : What legislation meant to constrain race within prejudicial boundaries was enacted? How did the various groups you researched fight this legislation?
Kotler text-profit marketing strategies : According to Kotler text, what are the primary drivers for applying for-profit marketing strategies to a nonprofit organization?
Part of a surgical admitting process : Part of a surgical admitting process orderlies are available to escort patients to the pre-surgery preparation area. Patients are not allowed to go by themselves as a matter of policy.
Repeat these questions by writing functions : Repeat these questions by writing functions that receive the arrays as constant reference parameters and return the appropriate values through the function name (via return statement). The function header could look like:
Design an object-oriented java application : You are to design an object-oriented Java application to let the user play a dice game that uses two dices. The player bets on a value and the dices roll
Write a java program using the java graphics : Your task for this assignment is to write a Java program using the Java Graphics class to create an example of a computer generated image. This is an opportunity for you to explore computer graphics and exercise some individual creativity.
Identity tangible and intangible benefits of the new payroll : suppose you own a travel agency in a large city you have many clients but growth has slowed somewhat. some long term employees are getting discouraged, but feels that there might be a way to make technology work in favor. use your imagination and sug..
Code skeleton to declare a class named date : Complete the following code skeleton to declare a class named Date. The class should contain variables and functions to store and retrieve a data in the form 4/2/2012.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd