KnowledgeBoat Logo

Computer Applications

Write a method which is used to swap the values of two memory locations by using a third variable.

User Defined Methods

60 Likes

Answer


void swap(int a, int b) {
    int c = a;
    a = b;
    b = c;
    System.out.println("a = " + a + "\t" + "b = " + b);
}

Answered By

36 Likes


Related Questions