Geeksforgeeks

Timer is Running

Given two non-negative numbers X and Y. The task is calculate the sum of X and Y. If the number of digits in sum (X+Y) are equal to the number of digits in X, then print sum, else print X.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two numbers X and Y.

**Output:**

For each test case, print the required answer.

**Constraints:**

1<=T<=500

1<=|Digits in X,Y|<=100

**Example:**

**Input:**

2

25 23

100 1000

**Output:**

48

100

**EXPLANATION:**

TestCase2: Since 100+1000=1100 which has 4 digits while 100(i.e X) has only 3 digits.Hence our answer will be 100 as per the prob statement.

Author: arun03

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.

jainshubham52535 | 529 |

Pathak1899 | 436 |

yashdip123 | 380 |

kirtidee18 | 377 |

jots62 | 351 |

kirtidee18 | 1057 |

ykaushik | 752 |

aggarwalvatsal5 | 741 |

harbilassingh | 576 |

pmr_3689 | 570 |

blackshadows | 5456 |

Ibrahim Nash | 5450 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4827 |

Login to report an issue on this page.