Gadgets

Monday, 23 November 2015

Swapping two numbers using third variable

Swapping two numbers using third variable
public class Swapping {
    public static void main(String[] arg){
        int a=10,b=20,c;
        c=a;
        a=b;
        b=c;
        System.out.println("a value is : "+a+" b value is :"+b);
    }   
}
Output:

a value is : 20 b value is :10

No comments:

Post a Comment