HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
1. Feel Free to ask and submit anything on and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

programming-basics: Program to find the reversed Sum

Reversed number is a number written in arabic numerals but the order of digits is reversed. The first digit becomes last and vice versa. Note that all the leading zeros are omitted. That means if the number ends with a zero, the zero is lost by reversing (e.g. 1200 gives 21). Also note that the reversed number never has any trailing zeros.

Your task is to add two reversed numbers and output their reversed sum.

Input Explanation:

The input consists of N cases (equal to about 10000). The first line of the input contains only positive integer N. Then follow the cases. Each case consists of exactly one line with two positive integers separated by space. These are the reversed numbers you are to add.

Output Explanation:

For each case, print exactly one line containing only one integer - the reversed sum of two reversed numbers. Omit any leading zeros in the output.

Sample Input:

24 1
4358 754
305 794

Sample Output:


Explanation: For the first sample input, 3 refers to the number of tests. In the first test 24 and 1 are the two numbers ,the reverse of 24 is 42 and for 1 it is 1. Hence the sum of 42 and 1 is 43. The reverse of 43 is 34.

programming x 168
basics x 171
Posted On : 2017-11-27 16:57:21.0
profile Divesh - Divesh


import java.util.Scanner;

public class ReversedSum {
public static void main(String[] args) {
Scanner input = new Scanner(;
int N = input.nextInt();
String[] inputs = null;
for(int i=0;i<N;i++){
inputs = input.nextLine().split(" ");

public static int getReversedSum(Integer number1, Integer number2){
int reversedSum=0;
int reverseNum1=getReverseNumber(number1);
int reverseNum2=getReverseNumber(number2);
return reversedSum;

public static int getReverseNumber(Integer number){
int reverseNumber=0;
char[] digits=number.toString().toCharArray();
int length = digits.length;
char[] reverseDigits = new char[length];
for(int i=length;i>=1;i--){
return reverseNumber;


Note: If you are just going to paste all the inputs on console at a time, Please put one blank line at the end of inputs then paste it or if you are going to enter inputs one by one then it´s not a problem.

Posted On : 2017-11-28 23:34:28
Satisfied : 4 Yes  0 No
profile Garima Gupta - Garima Gupta
Reply This Thread

Post Answer
Please Login First to Post Answer: Login login with facebook -