No of Carry Operations
Submissions: 2046   Accuracy:

23.2%

  Difficulty: Basic   Marks: 1

Given two numbers, the task is to find the number of carry operations required when two numbers are added as below..
1234
+
5678
--------
6912
--------
4+8 = 2 and carry 1
carry+3+7 = carry 1
carry+2+6 = 9, carry 0
carry+1+5 = 6

We need two carry operations in this example.

Input:
First line of input consists of an integer T, denoting the no of test cases. Then T test cases follow. Each test case contains two unsigned integers(n1,n2) less than 10 digits.

Output:
For each test case in a new line print the number of carry operations that would be required while adding n1 and n2.

Constraints:
1<=T<=50
1<=n1, n2 <= 9*10^10

Example:
Input:
3
123 456
555 555
123 594

 

Output:
0
3

1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vikraman
Author: vikikkdi


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.