Multiplying 2 huge numbers is a very common problem in programming competitions and interviews.I am attaching my code for this problem.
My algorithm:
1.Input the 2 numbers in a string say S1,S2
2.Consider one of the 2 number say S2 as a collection of many single digit numbers eg if s2=”3243″ then it is a collection of ’3′,’2′,’4′ and ’3′
3.Multiply each such digit with S1, taking care of the carry
Follow this link for the c++ implementation which handles upto 1000 digit long unsigned numbers.The code is well commented.If you come across any bugs in it,please let me know by post it here!
My code is not perfect, of course there is a scope of improvement.