Advertisements
Advertisements
प्रश्न
Write a method which is used to swap the values of two memory locations by using a third variable.
कोड लेखन
उत्तर
by using a third variable - call by value
void swap (int a, int b)
{
System.out.println(a + " " + b);
int temp = a;
a = b;
b = temp;
System.out.println(a + " " + b);
}
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 5: User - Defined Methods - EXERCISES [पृष्ठ ३३७]