1. ## Algorithm for multiplying linked lists?

Hi im trying to create a function to multiply two linked lists filled with integers.

I have a function that multyplies one list by 10(ie adds a 0 to end)
I have a function that reverses the list.
I have a function that multiplies two digits and returns the result along with any carry. (shown later)

when i first input numbers they go in backwards.

So inputing the number 43 generates a list of 3->4.
The add function gives the answer non backwards tho so adding 3->4 and 2->5 gives the list 5->9.

Now i need to create a multiply function. I just need a basic idea of how to do it.

Basically im thinking given two lists N1 and N2 to multiply:

Keep the first digit in N1 and multiply it with every number in N2 to get a list. Then add this list to 10 times the list generated by taking the second digit of N1 and multiplying by all the digits in N2.
Continue doing this untill all numbers in N1 have been exhausted and continually multiply the adding number by a different power of 10. Basically exactly how one would do it in real life.

Im having trouble seeing the code for this however.

So here is my multiply two digits function:

Code:
```int multiply_two_digits(int d1, int d2, int *carry_in, int *result, int *carry_out){
*result = d1*d2+*carry_in;
*carry_out=*result/10;
if(*result>=10){
*result=*result%10;
}
return 0;
}```
which returns the result and any carry.

Any ideas or tips? Everytime i try writing this function it gets way to complicated and i cant figure it out. Thanks for any help.

2. Write a function that adds one integer list to another. (looks like that's done)
Write another function that multiplies an integer list by an integer.
Then use what is sometimes called "grade school" multiplication, i.e. iterate over one list, and multiply the other list by the current number, and add the resulting list to some total.

3. Thx got it to work doing what you said altho you forgot to mention i need to also times it by 10 sometimes.

For instance
2222 *111 = 2222*1+2222*1*10+2222*1*10*10. I got it to work putting this into code so thx. The thing that helped me most was the suggestion to make a function that multiplies an entire list by 1 single int. THX .