answersLogoWhite

0

Sum of n numbers using array?

Updated: 8/18/2019
User Avatar

Wiki User

11y ago

Best Answer

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.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

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.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sum of n numbers using array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


C program to find sum of n numbers using functions over loading?

C does not support function overloading. Every function in the global namespace must have a unique name. However, to find the sum of n numbers, place the numbers in an array of appropriate size and pass the array to the following function: // Sum an array of n values int sum (int values[], unsigned n) { int result = 0; for (int i=0; i<size; ++i) result += values[i]; return result; }


Write a program to calculate the sum of n numbers using array?

int myArray[N]; //where N is a constant int mySum = 0; ... for (int arrayIndex1 = 0; arrayIndex1 < N; arrayIndex1++) { cin >> myArray[arrayIndex1]; } ... for (int int arrayIndex2 = 0; arrayIndex2 < N; arrayIndex2++) { mySum +=myArray[arrayIndex2]; } ...


Program to find sum of n numbers using recursion function?

int sum(n) { if (n==0) return 0; else return n+sum(n-1); }


Program in c to get the sum of n numbers present in an array using one dimensional array?

#include<stdio.h> #include<conio.h> main() { int num, n,sum=0,i=0; printf("enter the number of elements to be added "); scanf("%d",&n); printf("enter %d numbers",n); while(i<n) { scanf("%d",&num); sum=sum+num; i=i+1; } printf("the sum of %d numbers is %d",n,sum); getch(); }


C program to find sum of n number using for loop?

#include<stdio.h> void main() { long long int sum=0,n,i,b; printf("How many numbers do you want to add?\n"); scanf("%lld",&n); printf("Enter those %lld numbers\n",n); for(i=0;i<n;i++) { scanf("%lld",&b); sum=sum+b; } printf("Sum of all the numbers you entered is %lld",sum); getch(); }


How do you get the sum of consecutive cubed numbers?

The sum of the first n cubed numbers is: [n*(n+1)/2]2 which is the same as the square of the sum of the first n numbers.


Write a program to add array of N elements?

int sumArray(int N, int* A) { int sum = 0; do sum += A[N-1] while (N-- > 1); return sum; }


Java-find average using array?

public static final double getAverage(final int[] ns) { if (ns.length == 0) { return 0.0; } int sum = 0; for (int n : ns) { sum += n; } return ((double) sum) / ns.length; }


How do you find the average of n numbers?

The average of n numbers = (sum of n numbers) / (count of n numbers).


C program for displaying perfect numbers using nested loop?

for (n=1; n<1000; ++n) { for (sum=0, k=1; k<=n/2; ++k) if (n%k==0) sum += k; if (sum==n) printf ("%d\n", n); }


What is the c plus plus program for printing sum to n natural numbers?

main() { int i, n, sum=0; cout<<"Enter the limit"; cin>>n; for(i=0;i<=n;i++) sum=sum+i; cout<<"sum of "<<n<<" natural numbers ="<<sum; getch(); }