Write a program that declares a two-dimensional array named myFancyArray of the type double. Initialize the array to the following 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.

Answers

Answer 1

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;

}


Related Questions

window is a very popular operating system becouse of its _ environment .​

Answers

Window is a vary popular operating system because of its runtime and compatible environment .
hope it help
Windows is perhaps the most popular operating system for personal computers globally. ... Windows is very popular because it is pre-loaded in majority of the new personal computers. Compatibility. A Windows PC is compatible with most software programs in the market

Darcy was working on a presentation on playing chess. Because she chose the Checkerboard animation for her slide title, she had to use the same animation for her bullet points.

True
False

Answers

The answer is true
Helene
the answers is true of this question

Why is making a model, or prototype, important in the design process?

Answers

Explanation:

to size up and define your works organize and having a creative thoughts and imaginations in it to properly execute the measurement of the clothes.

Variable X is a *
Public Class Form)
Sub Example 10 Handles MyBase.load
Dim X As Integer
X = 10
MsgBox("The value of X is "& X)
End Sub

Answers

Answer:

Variable X is a local variable.

Explanation:

X exists only inside the sub.

write a technical term for following statements
1.The method applied to increase the life of computer and its assets.
2.The power regulating device this supplies constant power to the computer from its backup system.
3.The software used to scan, locate and detect the disk for viruses.

Answers

Answer:

1. Hardware Maintenance

2. Uninterrupted Power Supply (UPS)

3. Antivirus software

Explanation:

Antivirus software, or Anti-virus software (also known as AV software), otherwise called anti malware, is a PC program used to forestall, distinguish, and eliminate malware.

Antivirus software was initially evolved to identify and eliminate PC infections, thus the name. Be that as it may, with the expansion of different sorts of malware, antivirus software began to give security from other PC dangers. Specifically, current antivirus software can shield clients from: noxious program criminals.

A few items additionally incorporate security from other PC dangers, for example, tainted and noxious URLs, spam, trick and phishing assaults, online identity (privacy), web based financial assaults, social engineering techniques, advanced persistent threat (APT).

You have been asked to write a program that involves animals. Some animals are herbivores. Within this program, any animal that is not a herbivore is a carnivore. Which set of class definitions is most appropriate for this program

Answers

Incomplete question. The options:

class Animal :

class Herbivore(Animal):

class Carnivore(Herbivore) :

class Animal (Herbivore, Carnivore) :

class Herbivore :

class Carnivore

class Animal

class Herbivore (Animal) :

class Carnivore (Animal) :

class Animal:

class Carnivore (Animal) :

class Herbivore (Carnivore) :

Answer:

class Animal

class Herbivore (Animal) :

class Carnivore (Animal) :

what command in cisco IOS allows the user to see the routing table

Answers

Answer:

Show IP route command

Explanation:

How can you reboot a laptop?
How do you get an upgrade for a tower?
Lastly, How do u get a Virus Protection.

Answers

Question: How can you reboot a laptop?

Answer: Rebooting a computer simply means to restart it. If you're using Microsoft Windows, you can click the "Start Menu," click the "Power" button and click "Restart" in the submenu to restart your computer. If you still have problems with the computer, you can also choose the "Shut Down" option in the "Power" submenu to turn the computer off altogether, let it sit for a bit and then turn it back on.

Question: How do you get an upgrade for a tower?

Answer: You can upgrade your existing Tower installation to the latest version easily. Tower looks for existing configuration files and recognizes when an upgrade should be performed instead of an installation. As with installation, the upgrade process requires that the Tower server be able to access the Internet. The upgrade process takes roughly the same amount of time as a Tower installation, plus any time needed for data migration. This upgrade procedure assumes that you have a working installation of Ansible and Tower.

Question: How do you get a Virus Protection?

Answer: Use an antimalware app - Installing an antimalware app and keeping it up to date can help defend your PC against viruses and other malware (malicious software). Antimalware apps scan for viruses, spyware, and other malware trying to get into your email, operating system, or files.

Hope this helps! :)

Users report that the network is down. As a help desk technician, you investigate and determine that a specific router is configured so that a routing loop exists. What should you do next

Answers

Answer:

Determine if escalation is needed.

Explanation:

Since in this case, it has been determined that a specific router is configured in a way that a routing loop exists, the technician would further need to determine if the following issues are persistent;

having a switching loop on the networkgeneral router problemsrouting loopif there are broadcast storms.
Other Questions
Oftentimes, when a plant dies, the caretaker mayclaim they must have a "black thumb" because theycan't keep plants alive. They make sure the plantsget light and water and are insect-free but plants justdon't survive. What might be the problem? write a letter to mother describing you stay in the new boarding school The equation of the line that contains diagonal HM is y = 2/3 x + 7.What is the slope of the line that contains diagonal OE? wirte the fractional coefficient for 1 1/4 who wrote this quote WILL MARK BRAINLIEST "Without feelings of respect, what is there to distinguish men from beasts?" -Confucius Which pair shows equivalent expressions?A. 2x + 10 = -2(x - 5)B. -2(x + 5) = 2x - 10C. -2x - 10 = -2 (x + 5)D. -2(x - 5) = -2x - 10 Laura _____ deportes.1. practican 2. practicamos3. practico 4. practica If anyone knows the answer to this can you help me African American reaction to ww2 As you know people are held for years beforethey are executed when given the death penalty.Doyouthink it is cruel and unusual for a personto sit on death row for years before beingexecuted? Do you think it benefit society or thefamily of the individuals wronged to have personto stay alive for so long after such heinous crimeshave been committed? Feel free to agree ordisagree. Explain you view.1-2 paragraphs??? Pls help! a.) 2 is what percent of 1?b.) M is what percent of N?c.) What percent of 88 is 154? Jackson painted 80 bird house. 30% of the bird houses were painted green how many green bird houses did Jackson paint PLS HELP! WILL GIVE 100 POINTS 1. What are the first three books of The Old Testament?2.How many sides does a dodecahedron have?3.Banksy is most associated with which city? What has it felt like to consider your own stereotyping views of people A box contains 1 3/4 Pasta how many ounces of pasta are in the box Will give brainliestWhat type of bond is formed between atoms of a molecule of the product of this reaction? How can you determine which type of bond is formed between these atoms? 2 H2(g) + O2(g) 2 H2O(l) The __________ molecule is known as the universal energy source of the cell. *1 pointCaptionless ImageAMPATPGTPNADH Isabella's water bottle holds 4 cups of water. How many times can she fill her water bottle from a 1-gallon jug of water? Which system of linear inequalities is represented by thegraph?O y > x-2 and x- 2y < 4O y > + 2 and x + 2y < 4Oy>X-2 and x+ 2y < 4Oy>x-2 and x +2y help is science, if you don't know the answer just don't put anything /: