JavaScript: Subtract without arithmetic operators
JavaScript Math: Exercise-76 with Solution
Subtract Integers Without Arithmetic Operators
Write a JavaScript program to subtract one integer from another, without using arithmetic operators such as -, %, /, +, etc.
Test Data:
(200, 100) -> 100
(200, 300) -> -100
(-200, -300) -> 100
(200, 200) -> 0
Sample Solution:
JavaScript Code:
Output:
100 -100 100 0
Flowchart:
Live Demo:
Improve this sample solution and post your code through Disqus.
Previous: Swap three numbers.
Next: Two positive integers as string, return their sum.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics