This is my code and I’m not able to understand why it is not getting executed. Can some one help me out with this
Arrays - Sum of Two arrays
Hi @Legendankit
In this question there is a particular format in which you have to print an output. Like for input :
4
1 0 2 9
5
3 4 5 6 7
Your code is printing 3,5,5,9,6,END
but the correct format is 3, 5, 5, 9, 6, END
that is there should be space between , and next element.
After you make changes for this your code will fail for two test cases. These are the test case when you have input like :
4
7 0 2 9
5
9 4 5 6 7
here your code will give output as 0, 1, 5, 9, 6, END but the correct output is 1, 0, 1, 5, 9, 6, END
Basically these are the test cases when you have carry=1 and you are out of the for loop. So in order to correct this before print sum array you need to check for carry, if it is 1 then print "1, " first and then print the sum array.
Here is your corrected code :
If your doubt is clear then mark it as resolved.