Please help me in making this c++ program?

Home » Programming & Design » Please help me in making this c++ program?
Programming & Design No Comments

Other answer:

Ahsen:
I'm guessing that the objective is to determine the desired values in your code, rather than just displaying the pre-computed numbers. So, something like this:

#include <iostream>
#include <algorithm>

using namespace std;

const size_t N(3);

int totalDiagonal(const int m[N][N]) {
. . int sum = 0;

. . for (size_t i = 0; i < N; i++) {
. . . . sum += m[i][i];
. . }
. . return sum;
}

int maxArray(const int m[N][N]) {
. . const int *a = reinterpret_cast<const int *>(&m[0]);
. . return *max_element(a, a + N * N);
}

int main(int argc, char *argv[]) {
. . int matrix[N][N] = { {4, 6, 4}, {8, 7, 5}, {2, 9, 2} };

. . cout << "sum of diagonal = " << totalDiagonal(matrix) << endl;
. . cout << "max element = " << maxArray(matrix) << endl;

. . return 0;
}

#if 0

Program output:

sum of diagonal = 13
max element = 9

#endif

Robert J:
Lots of people would help – if you made some effort to do it yourself to start with.

As you are really saying "Do this for me", you need to re-think the question…

EddieJ:
#include <iostream>
using namespace std;

double elephant [][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

double totalDiagonal (double x [][3]) { return 1 + 5 + 9; }
double maxArray (double x [][3]) { return 9; }

int main () {
cout << "Diag: " << totalDiagonal (elephant) << endl;
cout << "Max: " << maxArray (elephant) << endl;
return 0;
}

roger:
#include <iostream>
using namespace std;
int totalDiagonal(void);
int maxArray(void);
int main() {
int elephant[3][3]={{4,6,4},{8,7,5},{2.9,2}}…
cout << totalDiagonal() << " "<<maxArray();
return 0;
}
int totalDiagonal(void){
return 13;
}
int maxArray(void){
return 9;
}
Ahsen:
if you don't want to answer then don't give a **** f**ku
Tom:
idk

LEAVE A COMMENT