# Thread: Urgent Help for homework - sum and difference(100digits) with carry

1. ## Urgent Help for homework - sum and difference(100digits) with carry

I am not good at programming, my teacher gave me to write a program and i have to finish it in 2 days. Here is the program which i have to write

Write a program to determine the sum Z=X+Y and the difference Z=X-Y, where X, Y are n-digit integer decimal numbers and n<=100.
He showed me how does it has to start but i need to complate it. an someone help me to finish my program, here is the what he wrote;

Code:
```n= 100
int x(100), Y(100), Z(101)

for (i=0, i<n,i++)
z[i]=x[i]+y[i]+c;
if (z[i]>9)
{c=1; z[i]=z[i]%10}```
who can create a C++ program from this content. and plus i need to write it for z=x-y too

2. Originally Posted by Fatal1ty
who can create a C++ program from this content. and plus i need to write it for z=x-y too
I can.

3. In other words, you've made NO PROGRESS in the last 6 weeks.
http://cboard.cprogramming.com/cplus...ifference.html

Try this on paper
Code:
```123456
789 +
------```
If you don't understand this much, then find an elementary maths text book.

Now imagine some boxes
Code:
```+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | \0|
+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 7 | 8 | 9 | \0|
+---+---+---+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |   |   | \0|
+---+---+---+---+---+---+---+---+---+---+---+```
Do the same, and keep track of which numbers go in which boxes.

Now imagine those boxes as char arrays
Code:
```char n1[10] = "0000123456";
char n2[10] = "0000000789"
char n3[10] = "";```
Repeat step 2, but mimic your actions as statements operating on the above arrays.

4. In other words, you've made NO PROGRESS in the last 6 weeks.
All aboard the failboat!