answersLogoWhite

0

int sumArray(int N, int* A) {

int sum = 0;

do sum += A[N-1] while (N-- > 1);

return sum;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you declare a string array and add elements to it in C plus plus?

You cannot add elements to a fixed array in C or C++. If, however, the array is declared as a pointer to an array, you can add elements by allocating a new array, copying/adding elements as needed, reassigning the new array to the pointer, and deallocating the original array.


How do you add a one more element to existing array?

To add one more element to an existing array, allocate a new array, copy the old elements to the new elements, and deallocate the old array; updating pointers as needed.


Write a program to add an array of 8 bit numbers using assembly language of Intel 8085?

To add an array of 8-bit numbers using Intel 8085 assembly language, you can use the following program structure: MOV M, A ; Initialize the accumulator LXI H, 2000H ; Load the address of the array into HL register pair MVI C, 08H ; Set the counter to 8 (number of elements) XRA A ; Clear the accumulator for the sum ADD_LOOP: MOV A, M ; Load the current array element into the accumulator ADD A ; Add it to the accumulator INX H ; Move to the next element in the array DCR C ; Decrement the counter JNZ ADD_LOOP ; Repeat until all elements are added ; The sum is now in the accumulator (A) This program initializes the address of the array, clears the accumulator, and iterates through each element, adding them together before storing the result in the accumulator.


Program to insert an element in array at beginning?

Answer: Use the unshift() Method You can use the unshift() method to easily add new elements or values at the beginning of an array in JavaScript. This method is a counterpart of the push() method, which adds the elements at the end of an array. However, both method returns the new length of the array To learn more about data science please visit- Learnbay.co


Sum of n numbers using array?

Set sum = 0, then add each of the elements of the array, one by one. Use a for loop to process each element of the array.Set sum = 0, then add each of the elements of the array, one by one. Use a for loop to process each element of the array.Set sum = 0, then add each of the elements of the array, one by one. Use a for loop to process each element of the array.Set sum = 0, then add each of the elements of the array, one by one. Use a for loop to process each element of the array.


Write a java program to maintain bank details using packages?

Use the Array Package. if you need help - add me on msn james_mc_123@hot dkjdkdjd mail.comp


How do you write a program in java to read ten numbers and print sum of ten integers?

Add the numbers into one variable as you read them in. But if you prefer, you can read the numbers into an array and then use a loop to add the numbers together.


Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


How do you find the average of rows and columns in a 2d array in java?

You add up all the array elements, then divide by the number of elements. You can use a nested for() loop in Java; inside the inner for() loop, you can both increase a counter (to count how many elements there are), and add to a "sum" variable.


How do you add two matrices using Linux shell script?

write ashell script to add awo matrix using array.


Write an algorithm to insert an item to a given location in sorted array?

To insert a number N into array A at index I: // Resize A if necessary If A is too small to add a new element then resize A // Right-shift all elements starting from position I For i = A.length to I A[i] = A[i - 1] // Insert new item A[I] = N


Write a program to add two 8 bit numbers in microprocessor 8051?

write it in 8085