Given two numbers, and the task is to find their addition using the minus (-) operator.
As we have discusses in C/C++ arithmetic operators that plus (+) operator adds the numbers and minus (-) operator subtracts the numbers. But adding two numbers using minus (-) operator can also be done – It's a simple mathematical trick.
As we know that, minus and minus becomes plus. Thus, to add two numbers – we can subtract the negative of the second number from the first number.
first_number - (-second_number)
Example:
Input:
x = 10
y = 20
Operation:
result = x - (-y)
Output:
result = 30
Program:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer