Answer this c++ Q i have a exam?

write a program to add two large integers with up to 300 digits one approcah is to treat each number as al list each of whose element is a block of digit of the number for example the integer 179.534.672.198 might be stored with block [0] =198 block [1] =672 block [2] = 534 block [3] = 179 then add to integer (lists) element by elment carrying from one elment to the next elment when necessary
There is no question there, but it sounds easy.
Write a program to add two large integers with up to 300 digits. One approach is to treat each number a list, each of whose elements is a block of digits of the number; for example, the integer "179,534,198" might be stored with block [0] = 198, block [1] = 672, block[2] = 534 and block [3] = 179.

Then add to integer lists element by element carrying from one element to the next when necessary.


I translated it into legible English, although I'm unsure what the last sentence is meant to mean.

That looks like you should make a LIFO stack (an std::vector of ints?) and each element is <= a tenth of the total number.

You would use std::cin to get a 3 digit number and then store it to the vector with vector.push_back(new_3_digit_number).

jsmith is right, that is easy. I hope I clarified things.
Last edited on
the Qu is addition 2 array by addition them by 3 digit on evrey block and when u + them like 198+926=1124 its will record it by using 3 digit 1.124 this will record 124 in first block but how we will + 1 to the next block .
if u can write it C++ not C++ data structures
plzzzz
thx for help
No, do it yourself.
You have to write some code for it yourself first; we'll help you with individual errors. The answer would depend on how you are implementing all of it.
plzzz i ask for help
We aren't going to write the whole answer for you. That would
1. Take time and effort.
2. Constitute cheating.
3. Be detrimental to your own learning.

If you're going to be lazy, then so am I. If you try to do the question and ask for specific help, I (we) will help you.
okz when i make to array how i will but evrey 3 digit in block that is my Qu
i looking for reply
Okay; when I make an array; how will I put every 3 digit block in the array? That is my question.
I am waiting for your response.


Can't you at least try to be helpful yourself, so I can help you? I can barely read your posts.

That looks like you should make a LIFO stack (an std::vector of ints?) and each element is <= a tenth of the total number.

You would use std::cin to get a 3 digit number and then store it to the vector with vector.push_back(new_3_digit_number).


I answered that question already. A vector is almost like an array, you use it in a similar way.

http://www.cplusplus.com/reference/stl/vector/
Topic archived. No new replies allowed.