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
Gnesinka [82]
4 years ago
12

Write the definition of a method named sumArray that has one parameter, an array of ints. The method returns the sum of the elem

ents of the array as an int.
Computers and Technology
1 answer:
White raven [17]4 years ago
8 0

Answer:  Following code is in C++

#include<iostream>

using namespace std;

int sumArray(int a[])  //take array as argument

{

   int s=0,i;

   for(i=0;i<5;i++)

       s+=a[i];  //sums every element

   return s;

}

int main() {

   int sum,a[]={1,7,4,9,6};

   sum=sumArray(a);   //calling the function

   cout<<"Sum of array is : "<<sum;   //printing sum to console

return 0;

}

OUTPUT :

Sum of array is : 27

Explanation:

In the above mentioned code, an array is declared and initialized at the same time. A variable sum of int type stores sum returned the function sumArray() and then it is printed to the console. In the function sumArray(), a variable s of data type int is initialized with value 0 and a loop is executed in which every element of the array is added. At last, s is returned.

You might be interested in
I WILL GIVE BRANLIST
qaws [65]

Answer:

space alignment

Explanation:

I'm not sure just taking a guess cuz I'm bored lol

4 0
3 years ago
Read 2 more answers
Real GDP removes any inflation from the calculation of GDP. Why is it important to remove a general increase in prices from the
Katen [24]
<span>C. Not including inflation into the caluculation will over-estimate the GDP.</span>
8 0
4 years ago
If they spend all night writing computer programs, Laurence can write 10 programs while Carrie Anne can write 5. If they spend a
kondaur [170]

Answer:

Laurence can write 10 programs while Carrie Anne can write 5.

Laurence can make 6 sunglasses while Carrie Anne can make 4

Explanation:

3 0
3 years ago
What is the contents of the vector names after the following statements? vector names; names.push_back(“Ann”); names.push_back(“
SIZIF [17.4K]

Answer:

ann, cal

Explanation:

4 0
3 years ago
HELP ME PLEASE <br> Can you help get back my ro blox account: (LOLCrashForce)
abruzzese [7]

Answer: sorry we cannot help

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Which one of these is the most commonly used hardware interface for attaching peripherals to a microcomputer?
    8·1 answer
  • 4 types of system software
    10·2 answers
  • To remove an embedded chart, you should _____ it and press the DELETE key.
    14·2 answers
  • What can you do to stop a computer from repeatedly restarting in a continuous loop?
    13·1 answer
  • Which part of a formal email is optional
    6·2 answers
  • (1 consider the following function definition: int func(int x, double y, char u, string name { //function body } which of the fo
    7·1 answer
  • What did major networks do to combat audience erosion in the 1990s?
    15·1 answer
  • What are your undertale + au ships?
    15·1 answer
  • What are the main techniques used to help manage test anxiety? Check all that apply.
    6·2 answers
  • Explain in brief terms some of the technology and developments that were important in the history and development of the Interne
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!