Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   need help asap!!!on a problem!!!! (http://www.go4expert.com/forums/help-asapon-t11477/)

pugo112 19Jun2008 19:40

need help asap!!!on a problem!!!!
can u help me on this prob..:(


For the purposes of this problem we will define a large number as a positive whole number with at least eight digits. For example, 123456789 is a large number. Large numbers must NOT be expressed in exponential form.

Write a program that:

(1) asks for two inputs.




(2) then calculates the product of your two large numbers and prints;

THE PRODUCT OF your first large number
AND your second large number
IS the calculated product.

Test your program with 1234512345123451234512345 as your first large number and 9876598765987659876598765 as your second large number.


using namespace std;

int product(int, int);

int Array;

int main()
        const int SIZE=25, MES=25;
        int x, y;
        int myArray[SIZE], myarray[MES];

        cout<<"Enter Your First Large Number: "<<endl;

        cout<<"Enter Your Second Large Number: "<<endl;

        cout<<"The Product Of "<<myArray[SIZE]<<" and "<<myarray[MES]<<" is "<<Array<<endl;

        return 0;

simcopter 3Jul2008 02:34

Re: need help asap!!!on a problem!!!!
I'm not going to do your homework for you, but. I think the main problem is the way you are trying to store the large number.

Do you understand what this problem is trying to teach you? you cannot store a really large number as an integer. so your cin line is not going to work. you need to come up with a better way of handling the integers and doing the addition/handling overflow.

aali 22Jul2008 14:23

Re: need help asap!!!on a problem!!!!

the array as
int long arr[mes];
int long ar2r[size];

seangtz 24Jul2008 15:10

Re: need help asap!!!on a problem!!!!
As per my knowledge I would suggest you that don't try to store large number.

Rahul jolly 30Jul2008 11:06

Re: need help asap!!!on a problem!!!!
I think you should treat the numbers as arrays of signed characters. Take the ordinary manual multiplication method and implement it on this data layout. For example, your algorithm will start with the least significant (rightmost) digit and multiply it by each digit in the other number, summing and computing carry as it goes.

You can also consider using Karatsuba's Algorithm, you'll find a lot on internet for Karatsuba's Algorithm

sofprog66 1Aug2008 06:19

Re: need help asap!!!on a problem!!!!
Just use "double" as your variable decleration.

Rahul jolly 1Aug2008 09:48

Re: need help asap!!!on a problem!!!!
i think even double and long double will reach their limits at a point.

All times are GMT +5.5. The time now is 02:37.