Status
Not open for further replies.

Little Girl

Member
11
2011
0
0
C++ Help Required.

the user puts in some numbers and we read it and store it in reversed.. cuz we need to add the arrays.. and when we r adding we have to make sure if there is a carry we include that and so on.. and let's say the user entered 1 number to be 4 digits and 2nd number to be 4 digits.. and we globally declared that max allowed will be 4 but if their sum end up being 5 digits then we have to give error that it over flows.. and if their sum is within the boundary then print out the sum on the screen

this is what I have for the read function'
PHP:
bool ReadBigInt(BigInt& num)
{
string s;
cin >> s;
int len = s.length();
if (len > MAX_DIGITS)
return false;
else
for (int i = len - 1; i >= 0; i--)
num.Digits[len-i-1] = s[i] - '0';
return true;

I need to write one function for printing and one for adding.. but I can't figure out how to do the sum with the carry and so on in actual problem max will be 50 digits so we have to write a function in general tht will work with however many digits user enters from 1 to 50. to test the program we will change the max to 4 or 5 to see if the program runs properly


If you can't help me regarding code please tell me some logically points ill try to code myself.
 
Status
Not open for further replies.
Back
Top