i have an integer like this:1
4
3
2
1
1
3
8
1
1
1
1
1
2
1
6
2
3
1
12
what can i do to add each individual number together like this: 4+3+2+1+1+1+3+8 etc?
gibson.nathan
0
Junior Poster in Training
Recommended Answers
Jump to PostI'm confused about the question. What do you mean you have an integer like this? Need more info
Jump to PostWhen you are reading these integers in from your file, you can either insert them into an array, or just add them together as you read the line. When you read a line in from file, if you read it as text do the following to convert it to an …
Jump to Postsir according to me
u have to push all numbers in a stack and thn using plus opretor pop out these all thn u will get sum of all numbersNo stack is required to calculate the sum. Set up a sum variable and initialize it to 0. Read in …
Jump to PostThat would depend on the details you haven't supplied - such as where this data is coming from.
All 15 Replies
jmaat7
0
Light Poster
ajeet choudhary
0
Newbie Poster
cgeier
187
Junior Poster
VernonDozier
2,218
Posting Expert
Featured Poster
gibson.nathan
0
Junior Poster in Training
Ezzaral
2,714
Posting Sage
Team Colleague
Featured Poster
gibson.nathan
0
Junior Poster in Training
VernonDozier
2,218
Posting Expert
Featured Poster
gibson.nathan
0
Junior Poster in Training
santosh.garg
0
Newbie Poster
gibson.nathan
0
Junior Poster in Training
santosh.garg
0
Newbie Poster
VernonDozier
2,218
Posting Expert
Featured Poster
gibson.nathan
0
Junior Poster in Training
VernonDozier
2,218
Posting Expert
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.