This code supposed to read up to 30 digits and get input from users twice. example input:
input first number: 12
input second number: 123458
result: 123470
I have no idea to do it. I found this code randomly and edit a lil bit and it does not work. A hand will be highly appreciated.
Hmm, so you want to take input for 2 30-digit long numbers, and be able to add them? Is that what you want? if yes, then you'll have to make two character array of 30 element blocks, store the 30digit numbers in it, type-cast into int form, and then add them using manual addition algorithm... (PS - Don't copy other programs, plagiarism is a bad habit...) :) If you want more help, post what exactly do you need help with...
Alright. Actually i thought the 30 characters arrays has been declared. No? I realized that i posted only half of the code. Yes, plagiarism is bad, but i couldn't help it :P. Do i need to do swap values in this code. Yes, you are right, i want to input twice for 30 digits long numbers.
The way you're taking input for the numbers. cin requires you to hit Enter, so it will take input for a number 60times in your program... Use a get function of some sort that accepts the character asa it is entered.....
Also, I doubt your swap function would work.. Coz when you swap all the values halfway through, you've reversed the array... And then when you go from half till the end, you end up reversing it back..
Line 55 and 59, your loop starts from 0, and you are checking an array member of -1... what do you think that will do? I guess it might be returning some garbage value... rectify that too...