₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,367 members, 8,426,252 topics. Date: Saturday, 13 June 2026 at 11:14 PM

Toggle theme

Help Out With Algorithm To Add Multiple Numbers - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Out With Algorithm To Add Multiple Numbers (945 Views)

1 Reply (Go Down)

Help Out With Algorithm To Add Multiple Numbers by Seconsol92(op): 7:56am On Jun 22, 2015
please programmers in the house help me out with algorithm to add multiple numbers (ie 2+3+5+7).
Re: Help Out With Algorithm To Add Multiple Numbers by FincoApps(m): 9:59am On Jun 22, 2015
1. Store each number in an int array
2. Add up the array using a for loop

int[] arr;
int sum = 0;
E.g for(int i=0; i<arr.length; i++)
{
sum = sum + arr[i];
}

But what language are you working with ?
Seconsol92:
please programmers in the house help me out with algorithm to add multiple numbers (ie 2+3+5+7).
Re: Help Out With Algorithm To Add Multiple Numbers by Greatfes17: 2:55pm On Jun 22, 2015
Find a way to store all the numbers. Then use a loop to go through the numbers and add them as it iterates.

In python you can store the numbers in a list or tuple, then use 'for loop' to iterate and add them as you go.

Simpler than anything, pass it as argument to inbuilt sum function.

Happy coding
Re: Help Out With Algorithm To Add Multiple Numbers by Seconsol92(op): 4:59pm On Jun 22, 2015
FincoApps:
1. Store each number in an int array 2. Add up the array using a for loop
int[] arr; int sum = 0; E.g for(int i=0; i<arr.length; i++) { sum = sum + arr[i]; }
But what language are you working with ?
thanks for the help. i am working with java
Re: Help Out With Algorithm To Add Multiple Numbers by FincoApps(m): 5:51am On Jun 23, 2015
You welcome smiley
Seconsol92:
thanks for the help. i am working with java
Re: Help Out With Algorithm To Add Multiple Numbers by babatope88(m): 11:47am On Jun 23, 2015
Are the numbers in predictable sequence? If No, then try the suggested method above. But the given example look like a sequence, sum = n/2(2a + (n - 1)d)
Where n is the number of element
d is diff btw first term and 2nd term common difference.
This would be more faster.
Re: Help Out With Algorithm To Add Multiple Numbers by babatope88(m): 11:50am On Jun 23, 2015
Oh!!! not a sequence. Abaachabacha
1 Reply

Your Toughest AlgorithmWrite An Algorithm To Add N Binary NumbersHelp With Algorithm Of Basic Operations Of A Calculator234

Please Who Is Good At Programing I Want To Learn.STATA TutorHow To Repair OST 2010 Data?