![]() |
VOOZH | about |
Given two Integers A and B, your task is to find the sum and difference of two numbers.
Examples:
Input: A = 4, B = 9
Output: Sum = 13 and Difference = -5
Input: A = -3, B = -2
Output: Sum = -5 and Difference = -1
The problem can be solved using arithmetic operators.
Operations on Numbers:
- Addition (+): This operation is used to add the inputs to get the output. For example, when 2 is added to 3 the resultant will be equal to the sum of both the numbers which is equal to 5, (2 + 3 = 5).
- Subtraction (-): This operation is used to subtract the inputs to get the result. For example, when 3 is subtracted by 2 the resultant will be equal to the difference of both the numbers which is equal to 1 (3 – 2 = 1).
Step-by-step algorithm:
Below is the implementation of the above approach:
Sum of 4 and 9 = 13 Difference of 4 and 9 = -5
Time Complexity: O(1)
Auxiliary Space: O(1)