# need help asap!!!on a problem!!!!

Discussion in 'C++' started by pugo112, Jun 19, 2008.

1. ### pugo112New Member

Joined:
Jun 19, 2008
Messages:
1
0
Trophy Points:
0
can u help me on this prob..

LARGE NUMBER

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:

WHAT IS THE FIRST LARGE NUMBER?

WHAT IS THE SECOND LARGE NUMBER?

and

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

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

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

Code:
```#include<iostream>
#include<cmath>
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;
cin>>myArray[x];

cout<<"Enter Your Second Large Number: "<<endl;
cin>>myarray[y];

Array=myArray[SIZE]*myarray[MES];

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

return 0;
}

```

2. ### simcopterNew Member

Joined:
Jul 2, 2008
Messages:
2
0
Trophy Points:
0
Occupation:
Simulations Software Engineer
Location:
Phoenix, AZ
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.

3. ### aaliNew Member

Joined:
Jul 16, 2008
Messages:
18
0
Trophy Points:
0
Occupation:
student
Location:
declare

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

4. ### seangtzNew Member

Joined:
Jun 6, 2008
Messages:
126
3
Trophy Points:
0
As per my knowledge I would suggest you that don't try to store large number.

5. ### Rahul jollyNew Member

Joined:
Jul 30, 2008
Messages:
3
0
Trophy Points:
0
Occupation:
Software Engineer
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

6. ### sofprog66New Member

Joined:
Jul 8, 2008
Messages:
29
0
Trophy Points:
0
Just use "double" as your variable decleration.

Joined:
Jul 30, 2008
Messages:
3