How to reverse the final output in this?
Here c is the carry which is getting added to the next number and r is the output which is equal to the last digit of the sum
plzz tell???
@garganshul151 hey anshul your logic is wrong in the question it is not a 2d arrays it is two different arrays.
check this one…
???btaona
@garganshul151 hey anshul this is not right approach to solve this question
follow this algorithm to solve this question
1.Traverse both the arrays simultaneously from the end until we reach the 0th index of either of the array.
2.While traversing each element of array, add an element from both arrays and carry from the previous sum.
…………2.1 Store the unit digit of the sum(obtained by doing - sum%10) in the ans array.
…………2.2 forward carry(obtained by doing - sum/10) for the next index sum.
3.After the loop ends we are left with one of the arrays and the carry.
4.We will now repeat step 2 but now for one array which is left after the loop.
5.If carry !=0 then store the carry in the 0th index of ans array.
6.Print the ans array
if you will not to implement this question do tag I will help you out .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.