Pergunta de entrevista da empresa Ziffity

Swap the numbers without using the third variable

Resposta da entrevista

Sigiloso

14 de out. de 2019

Using Scanner to get the value import java.util.Scanner; public class Swapnum { public static void main(String[] args) { Scanner sf = new Scanner (System.in); int a; System.out.print("Enter the Value of a : "); a=sf.nextInt(); int b; System.out.print("Enter the value of b : "); b=sf.nextInt(); a=a+b; b=a-b; a=a-b; System.out.println("value of a is :" +a); System.out.println("value of b is :" +b); } }