Faulty Key Problem Statement

Ninja needs to create a function to calculate the sum of two integers without using the “+” operator due to keyboard issues. Help Ninja find the sum of two numbers without using the "+" operator anywhere in your code.

Note:
You should also not use the increment "++" operator either.

Input:

The first line contains an integer ‘T’ denoting the number of test cases. Each test case consists of one line with two space-separated integers, A and B.

Output:

For each test case, output the sum of A and B without using the "+" operator on a new line for each test case.

Example:

You are given A = 4, B = 6, their sum should be output as 10.

Constraints:

  • 1 <= T <= 100
  • -10000 <= A, B <= 10000

Where ‘T’ is the number of test cases, and ‘A’ and ‘B’ are the integers.

AnswerBot
8d

Calculate the sum of two integers without using the '+' operator or the '++' operator.

  • Use bitwise XOR to add the two numbers without carrying.

  • Use bitwise AND and left shift to handle the carry.

  • Repeat ...read more

Help your peers!
Add answer anonymously...
INCA INFOTECH TECHNOLOGIES Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter