Hello guys was watching the tut for dynamic memory... (ill try to jump boring stuff) and failed to do something...
So lets get to the point, What i want to do is when the user types the many numbers they ask AND Then type all of his numbers, i just want to get sum of all those numbers he/she inputted... i just wanted to test DM with a full info, on calulator im making ( which its specifically is a Circuit calculator of Series And Paralel )
PS. im not asking for homework... only a piece of work im making i just need to know how to do math in p[n] << has in the tutorial.
Why don't you use a variable to store the sum of all numbers inputted by the user.
1 2 3 4 5 6 7 8 9 10
// Example
int sum = 0, amount, current;
cin >> amount; // Get amount of numbers to store.
int *array = newint[amount];
for (int i=0; i < amount; i++) {
cin >> current;
array[i] = current;
sum += current;
}
You can also go over your array once you're done adding the numbers but that would be redundant.