Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to code the following question in C++ ? Design a class named Location for lo

ID: 3727447 • Letter: H

Question

How to code the following question in C++ ?

Design a class named Location for locating a maximal value and its location in a two dimensional array. The class contains public dat fields row, column and maxValue that store the maximal value and its indices in a two dimensional array.

row and column as int type and maxValue is double type.

Write a method that returns the location of the largest element in a 2 dimensional array

Location locateLargest(double ** a) ;

return value is an instance of Location.

Write a test program that prompts the user to enter a two dimensional array and displays the location of the largest element in the array

Explanation / Answer

#include<stdio.h>

int main ( ) {

/* 2D array declaration */

int disp[2] [3] ;

/*Counter Variables for the loop*/

int i, j ;

for (i=0; i<2; i++) {

for(j=0; j<3; j++) {

printf ("Enter value for disp[%d] [%d] : ", i, j) ;

scanf(" %d", & disp[ i ] [ j ] ) ;

}

}

/ /Displying array elements

printf("Two Dimesional array elements: ") ;

for (i=0; i<2; i++) {

for(j=0; j<3; j++) {

printf ("%d ", disp[ i ] [ j ] ) ;

if (j==2) {

printf(" ") ;

}

}

}

return 0;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote