Help

I have an assignment in my C++ course where I need to get a user defined amount of integers and the integers themselves are user defined and I need to get their sum. How do I go about doing this?
1) Ask the user how many integers he/she wants
2) Dynamically Allocate an int array of this size
3) Create a loop that asks the user what integers he/she wants to add
4) Create an integer and loop through the array adding the values in the array to it
5) Output the total
1
2
3
4
5
6
7
declare vars
prompt user to enter desired amount of integers
read into variable
create an array of ints with the size of a variable
loop through each elements asking for input
add all elements together for a sum
display sum


understood?
There is no need for an array. You can simply add each input to a running sum and then discard the values.
oh, i read the problem wrong. i was under the impression the input would need to be stored in a data type. Listen to cire, but if you're looking for a more complex and inefficient way, keep on following my other post.
Last edited on
There is no need for an array. You can simply add each input to a running sum and then discard the values.

Ah, yes.
Last edited on
Alright, I was about to say we haven't covered arrays in my class yet, so I doubt the teacher expects us to use it. Thanks for your replies
Topic archived. No new replies allowed.