answersLogoWhite

0


Best Answer

int sum(int list[], int arraySize) {

int sum=0;

for(int i=0; i<arraySize; ++i )

sum+=list[i];

return(sum);

}

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C plus plus prog a function sum that returns the sum of all Values in the given array int sum int list int arraySize?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

C plus plus prog a function mean that returns the mean of all Values in the given array double mean int list int arraySize?

double mean(int list[], int arraySize) { double result=0; for(int i=0; i&lt;arraySize; ++i ) result += list[i]; return(result/size); }


How to print the reverse of an array without using backward loop?

int youArray[arraysize] = {...};...for (int i = 1; i


How do you find the greatest number through C programming?

The simplest way is usually to iterate through an array using a loop and store either the index or the value of the highest number you find. For example: int findLargestIndex(int *array, int arraysize) { int largestIndex = 0; for(int i = 0; i &lt; arraysize; i++) { if(array[i] &gt; array[largestIndex]) largestIndex = i; } return largestIndex; }


How is an array name interpretedwhen it is passed to a function?

An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.


How do we pass array to function of java?

Let the function be private void processArray(int[] arInts); to call this 1. Create a local array variable, set the values and pass it int[] arIntInp = {0,1,3}; processArray(arIntInp); 2. Create an array on the fly and pass it processArray(new int[]{0,9});

Related questions

C plus plus prog a function min that returns the minimum of all Values in the given array int min int list int arraySize?

int min(int list[], int arraySize) { int min=arraySize?list[0]:0; for(int i=1; i&lt;arraySize; ++i ) if(list[i]&lt;min) m=list[i]; return(min); }


C plus plus prog a function mean that returns the mean of all Values in the given array double mean int list int arraySize?

double mean(int list[], int arraySize) { double result=0; for(int i=0; i&lt;arraySize; ++i ) result += list[i]; return(result/size); }


Write an Algorithm to delete a last element from the array?

// Assuming you dynamically allocated this array using "new"... delete array[arraysize - 1]; arraysize--;


How do you make a C plus plus program that arrange the the numbers in ascending order?

Heres something i whipped up in a hurry... This uses the Bubble Sort method found (related links) #include &lt;iostream&gt; using namespace std; int main(int argc, const char* argv) { int arraysize = 5; //Unsorted array size int array [] = { 5, 3, 4, 2, 1 }; //The array of numbers itself //Display the unsorted array cout &lt;&lt; "Before: {"; for (int c=0; c &lt;= arraysize; c++) { cout &lt;&lt; array[c]; if (c != arraysize) { cout &lt;&lt; ","; } } cout &lt;&lt; "}" &lt;&lt; endl; //Acctually sort the array int tmp=0; //Used for swaping values for (int loop=0; loop &lt;= (arraysize - 1); loop++) { for (int c=0; c &lt;= (arraysize - 1); c++) //The sort loop { if (array[c] &gt; array[c + 1]) { //Swaps the two values in the array tmp = array[c]; array[c] = array[c + 1]; array[c + 1] = tmp; //Cleanup tmp = 0; } } } //Display the sorted array cout &lt;&lt; "After: {"; for (int c=0; c &lt;= arraysize; c++) { cout &lt;&lt; array[c]; if (c != arraysize) { cout &lt;&lt; ","; } } cout &lt;&lt; "}" &lt;&lt; endl; return 0; }


What does array map do in php?

The array_map function in PHP loops over each elements of the passed array(s), and runs the given function. It then returns a new array that contains the values returned by each call to the given function.


How to print the reverse of an array without using backward loop?

int youArray[arraysize] = {...};...for (int i = 1; i


Can you write a character into a specific array index in c?

Yes, you can but the array must be char-type. ... int arraySize = 3;char myArray[arraySize]; ... for (intarrayIndex = 0; arrayIndex < arraySize; arrayInsex++) { cin >> myArray[arrayIndex]; //It will write three character (keys which you pressed) in myArray} ...


Find index number of an given array?

For instance, you have array of type int with a name myArray, and you do not know size of the array. You can use following statement to get it:int arraySize = myArray/myArray[0];arraySize gives you number of elements in myArray.


What is an Excel reference function that looks for a value in the top row of a table or array of values and returns the value in the same column from a row you specify?

hlookup


How do you find the greatest number through C programming?

The simplest way is usually to iterate through an array using a loop and store either the index or the value of the highest number you find. For example: int findLargestIndex(int *array, int arraysize) { int largestIndex = 0; for(int i = 0; i &lt; arraysize; i++) { if(array[i] &gt; array[largestIndex]) largestIndex = i; } return largestIndex; }


How do you flip an array without using flip function in PHP?

Use a for-loop starting at the length of the array and go backwards and build up a new array with the values.


How does PHP explode work?

Explode function splits a string into an array. For example: $str="Hello, How are you? i am fine."; explode("?",$str,2); it outputs two values in an array by splitting string into two values. Before question mark is considered as first value to array and after question mark is considered as second value. Finally, Array contains two values when you print it using print_r( ) function.