Help Out With Algorithm To Add Multiple Numbers - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Out With Algorithm To Add Multiple Numbers (943 Views)
| 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: |
| 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: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 |
| 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 |
Your Toughest Algorithm • Write An Algorithm To Add N Binary Numbers • Help With Algorithm Of Basic Operations Of A Calculator • 2 • 3 • 4
C++ Program That Convert Swidish Ore To Crown • Google Has Introduce Offline Searching And Navigation • .
