Swap two numbers without using third variable (A java Program)

Publicado el: 06 septiembre 2020
en el canal de: Knowledge Circle
1,351
104

Dear viewers,
In this video , I will thoroughly explain how to swap(Interchange) the values of two variables without declaring any extra variable.

Code-👇

import java.util.Scanner;
class swap
{
public static void main (String[ ] args)
{
Scanner sc=new Scanner (System.in);
int a,b;
System.out.println("Enter first number");
a=sc.nextInt();
System.out.println("Enter first number");
b=sc.nextInt();
System.out.println("Numbers before swapping");
System.out.println("a="+a);
System.out.println("b="+b);
a=a+b;
b=a-b;
a=a-b;
System.out.println("Numbers after swapping");
System.out.println("a="+a);
System.out.println("b="+b);
}
}


#javaprograms
#swaptwonumbers



Follow me on Instagram 👇

  / vinay_k_jaiswal  

Follow me on facebook 👇

  / vkj21  

Follow me on twitter 👇

  / vinaykumarsmart  


En esta página del sitio puede ver el video en línea Swap two numbers without using third variable (A java Program) de Duración hora minuto segunda en buena calidad , que subió el usuario Knowledge Circle 06 septiembre 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 1,351 veces y le gustó 104 a los espectadores. Disfruta viendo!