Add two numbers using ++ and / or | java program to add two numbers using ++ ; Returns value of x + y without using + ; If y is positive , y times add 1 to x ; If y is negative , y times subtract 1 from x ; Driver code
public class GFG { static int add ( int x , int y ) { while ( y > 0 && y != 0 ) { x ++ ; y -- ; } while ( y < 0 && y != 0 ) { x -- ; y ++ ; } return x ; } public static void main ( String args [ ] ) { System . out . println ( add ( 43 , 23 ) ) ; System . out . println ( add ( 43 , - 23 ) ) ; } }