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
In IDLE, which symbols are used for the prompt? <br>*** <br>&lt;&lt;&lt;<br> &gt;&gt;&gt;<br> ---​
Norma-Jean [14]

Answer: >>>

Explanation:

just finished the test and got this right

7 0
4 years ago
A client has gathered a very large amount of operational data, but struggles with how to apply Artificial Intelligence (AI) to a
Ivanshal [37]

Answer:A client has gathered a very large amount of operational data, but struggles with how to apply Artificial Intelligence (AI) to address its critical business problems.

4 0
3 years ago
Look at the slide. How could the slide best be improved? By reducing the number of visual aids by increasing the font size by da
azamat

Answer:

b.  by providing more information

Explanation:

5 0
3 years ago
Read 2 more answers
What are output statement in QBASIC?
Roman55 [17]

Answer:

<h2> hi. here's your answer ....</h2>

<h3>print statement provides output on the screen . it prints the value of the expression on the screen . if the expression list is blank , no character is print . the expression in the list may be numeric or string .</h3><h2>Hope you like it..</h2><h2>(◕ᴗ◕✿)</h2>

5 0
3 years ago
Students working at individual PCs in a computer laboratory send their files to be printed by a server that spools the files on
Vanyuwa [196]

Answer:

Explanation:

Disk space is a limited resource on the spooling partition and once it is filled the will cause a deadlock. Every single block that comes into the spooling partition claims a resource, and the one behind that wants resources as well, and so on. Since the spooling space is limited and half of the jobs arrive and fill up space then no more blocks can be stored, causing a deadlock. This can be prevented allowing one job to finish and releasing the space for the next job.

5 0
3 years ago
Other questions:
  • I'm curious why I would need to know this on a school learning site.
    12·1 answer
  • Which function is used to display a string value to the screen?
    8·1 answer
  • Design two subclasses of Employee…SalariedEmployee and HourlyEmployee. A salaried employee has an annual salary attribute. An ho
    12·1 answer
  • A Homecoming Crossword Puzzle
    12·1 answer
  • A qué escala está dibujado el plano del Instituto si sabemos que la puerta principal de entrada tiene un ancho 3,40 metros y en
    14·1 answer
  • Type the correct answer in the box. Spell the word correctly.
    15·2 answers
  • . Is it conceivable to design a secure operating system for these computer systems? Give arguments for and against.
    6·1 answer
  • 9.6 Code Practice, this is in Python, I need its quick!
    13·1 answer
  • A list cannot use appendleft but a _____ can.
    11·1 answer
  • Lucy is trying to decide what sources to use in her literature review. The type of sources Lucy will use in her literature revie
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!