1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Harlamova29_29 [7]
3 years ago
12

Write a program that declares a two-dimensional array named myFancyArray of the type double. Initialize the array to the followi

ng values: 23 14.12 17 85.99 6.06 13 1100 0 36.36 90.09 3.145 5.4 1. Create a function that will return the sum of all elements in the array. Call this function from main and print out the result. 2. Create a function that will use a nested loop to display all the elements in the array to the screen. Call this function from main.
Computers and Technology
1 answer:
kirill115 [55]3 years ago
7 0

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;

}

Download cpp
You might be interested in
Which of the following statements about security in the network is true?
Ilya [14]
I believe that answer A is true
5 0
2 years ago
(e) The entries in each column of the array A are sorted into strictly increasing order.
gizmo_the_mogwai [7]
The answer is 3 because
5 0
2 years ago
HELP!!! What would var d=?
sergiy2304 [10]

Answer:

51015

Explanation:

Var b is a string, and it'll treat addition like <em>string concatenation </em>(aka just adding a message.) Since it's concatenation, it'll then turn the numbers/integers into strings.

This kind of behavior might be different depending on the language, though. Some languages might not allow this. (For example, C and C++)

7 0
3 years ago
Which of the following protects against cave-ins? A. All answer choices protect against cave-ins B. Shielding C. Shoring D. Slop
babunello [35]
I think it is b idk if it is 100% right
4 0
3 years ago
Read 2 more answers
(EASY)
AnnyKZ [126]
If you go to a college website you will see the it has .edu in the URL extensions.
3 0
3 years ago
Read 2 more answers
Other questions:
  • What are the types of action involving data base?
    14·1 answer
  • Hard drives are usually self-contained, sealed devices. Why must the case for the hard drive remain sealed closed?
    8·1 answer
  • The process of engineering design typically starts with what ?
    12·1 answer
  • Write a program that lets a maker of chips and salsa keep track of their sales for five different types of salsa they produce: mi
    8·1 answer
  • "To take advantage of these developments in the digital world, new approaches, concepts,instruments, and methods are needed, whi
    8·1 answer
  • The incident results in huge losses of revenue as a result their mobile app service is withdrawn. Investigators discovered a vul
    5·1 answer
  • To have different formatting for odd and even rows, select the _____ option.
    8·1 answer
  • A person appreciation of a food taste and flavor is commonly referred to as what
    14·1 answer
  • What is the significance of the Abstract section of a research paper? A. It contains important information such as the author, c
    5·1 answer
  • Could you give me Aidan Gallagher's wuasp number​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!