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
lukranit [14]
3 years ago
6

Write the definition of a function named sumArray that receives two parameters: an array of element type int and an int that con

tains the number of elements of the array. The function returns the sum of the elements of the array as an int.
Computers and Technology
1 answer:
Alinara [238K]3 years ago
8 0

Answer:

// here is program in C++.

#include <iostream>

using namespace std;

// function to calculate sum of elements of array

int sumArray(int ar[],int n)

{

   // variable

   int sum=0;

   for(int a=0;a<n;a++)

   {

   // calculate sum of all elements

       sum=sum+ar[a];

   }

// return sum

 return sum;

}

// driver function

int main()

{

 // variable

  int n;

  cout<<"enter the number of elements in array:";

  // read the number of elements

  cin>>n;

  // Declare an array of size n

  int ar[n];

  cout<<"enter "<<n<<" elements:";

  // read the elements of array

  for(int x=0;x<n;x++)

  {

      cin>>ar[x];

  }

   // call the function with parameter array and n

   // print the sum

  cout<<"sum of "<<n<<" elements of array is: "<<sumArray(ar,n)<<endl;

   return 0;

}

Explanation:

Read the number of elements and assign it to "n".Then create an array of size n of integer type.Read n elements of the array.Call the function sumArray() with parameter array and n.Here it will calculate the sum of all elements and return an integer which holds the sum of all elements.

Output:

enter the number of elements in array:5

enter 5 elements:3 6 12 9 5

sum of 5 elements of array is: 35

You might be interested in
Choose two technologies that you think would help the company meet its goals. Then fill in the chart below to compare the techno
elena55 [62]

Answer:

Good luck

Explanation:

Laptop and iPad

laptop because you can open many pages and tabs to help you multitask your goals

and iPad because most free business would be on an iPad and apps are cheap and would help you focus/help you work harder

7 0
3 years ago
Read 2 more answers
PLEASE HELP!
Morgarella [4.7K]
An query because his ideas are effective
8 0
4 years ago
Read 2 more answers
Which applications run on IHGs private cloud?
Svetlanka [38]

Answer:

Applications CSS and JvaP

Explanation:

6 0
4 years ago
A number of LC-3 instructions have an "evaluate address" step in the instruction cycle, in which a 16-bit address is constructed
hjlf

Answer: you want to list all LC structers

Explanation:

4 0
4 years ago
Which of the following describes the main purpose of a model?
nalin [4]

Answer:

to demonstrate how something works.

Explanation:

hope it helps Brainlist?

8 0
3 years ago
Other questions:
  • What is computer virus?
    8·1 answer
  • Describe the difference between gui and cli​
    9·1 answer
  • You can deselect multiple selected sheets beginning with the sheet1 tab by pressing the ____ key and clicking the sheet1 tab.
    15·1 answer
  • Două numere a și b sunt numite generatoare ale unui număr natural n dacă a∙b+[a/b]=n, unde s-a notat cu [c] partea întreagă a nu
    7·1 answer
  • In a certain computation, 90% of the work is vectorizable. Of the remaining 10%, half is parallelizable for an MIMD machine. Wha
    9·1 answer
  • If you’re the victim of cyber bullying behavior, besides contacting your teacher or the school, where else can you go to find in
    13·1 answer
  • In ____________, a large address block could be divided into several contiguous groups and each group be assigned to smaller net
    7·1 answer
  • A line graph is a great tool for showing changes over time. Why is a line graph better than other graphs at showing this type of
    6·1 answer
  • Join the class <br> The class code is hello112
    5·2 answers
  • What is the difference between concrete language and abstract language? give an example of each.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!