Answer:
This solution is provided in C++
#include <iostream>
using namespace std;
double sumFancyArray(double myarr[][6]){
double sum = 0.0;
for(int i = 0;i<2;i++) {
for(int j = 0;j<6;j++){
sum+=myarr[i][j];
}}
return sum;
}
void printFancyArray(double myarr[][6]){
for(int i = 0;i<2;i++) {
for(int j = 0;j<6;j++){
cout<<myarr[i][j]<<" ";
}
}
}
int main(){
double myFancyArray[2][6] = {23, 14.12, 17,85.99, 6.06, 13, 1100, 0, 36.36, 90.09, 3.145, 5.4};
cout<<sumFancyArray(myFancyArray)<<endl;
printFancyArray(myFancyArray);
return 0;
}
Explanation:
This function returns the sum of the array elements
double sumFancyArray(double myarr[][6]){
This initializes sum to 0
double sum = 0.0;
This iterates through the row of the array
for(int i = 0;i<2;i++) {
This iterates through the column
for(int j = 0;j<6;j++){
This adds each element
sum+=myarr[i][j];
}}
This returns the sum
return sum;
}
This method prints array elements
void printFancyArray(double myarr[][6]){
This iterates through the row of the array
for(int i = 0;i<2;i++) {
This iterates through the column
for(int j = 0;j<6;j++){
This prints each array element
cout<<myarr[i][j]<<" ";
}
}
}
The main starts here
int main(){
This declares and initializes the array
double myFancyArray[2][6] = {23, 14.12, 17,85.99, 6.06, 13, 1100, 0, 36.36, 90.09, 3.145, 5.4};
This calls the function that returns the sum
cout<<sumFancyArray(myFancyArray)<<endl;
This calls the function that prints the array elements
printFancyArray(myFancyArray);
return 0;
}