Java program to sum of two numbers without using + operator

sum of two numbers

import java.util.*;
class scan
{
 public static void main(String arg[])
  {
   int i,x,y;
   Scanner kb=new Scanner(System.in);
   System.out.println("Enter First Number");
   x=kb.nextInt();
   System.out.println("Enter Second Number");
   y=kb.nextInt();
   
   for(i=1;i<=y;i++)
    {
	 x++;
	}
	System.out.println("Sum of 2 Numbers is:- "+x);
  }
}

OUTPUT:-

sum of two  numbers

Leave a Reply

Your email address will not be published. Required fields are marked *