![]() |
This article will show you how to add two numbers without using Arithmetic operators in PHP. There are two methods to add two numbers, these are: Table of Content Using Bitwise OperatorsWe will use Bitwise Operator to add two numbers. First, we check num2 is not equal to zero, then Calculate the carry using & operator, and then use XOR operator to get sum of numbers, At last, shift the carry to 1 left. PHP
Output
Sum : 12 Using RecursionIn this section, we will use the above approach with Recursion to calculate the sum of two numbers. Example: PHP
Output
Sum : 12 |
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |