Computer Science, asked by Princehardy, 1 year ago

write a program to input two unequal numbers. Display the numbers after swapping their values in the variables without using a third variable.
(JAVA program using Stream Classes)

Answers

Answered by Fatimakincsem
8

Program to input two unequal numbers and then display the numbers after swapping their values in the variables without using a third variable.

public class Brainly {

public static void main(String[] args) {

 

 int first = 10;

 int second = 20;

 

 System.out.println("Before Swapping");

 System.out.println("Value of first is :" + first;

 System.out.println("Value of seond is :" + second);

 

 //add both the numbers and assign it to first

 first = first + second;

 second = first - second;

 first = first - second;

 

 System.out.println("After Swapping");

 System.out.println("Value of first is :" + first;

 System.out.println("Value of second is :" +second);

}

}

Answered by Sidyandex
4

The couple of minor errors are taking with system and thus println and functions for have space after the + as system.

This always denotes with system.out println and thus variable Java for carrying with swap numbers without using third variable.

Swapping is the process of exchanging the value of two variables with each others.

It contains two numbers and values can be assigned by 20.

Similar questions