ICSE Class 10 Computer Applications Question 17 of 43

User-Defined Methods — Question 17

Back to all questions
17
Question

Question 15

Write a function that interchanges the value of two integers A and B without using any extra variable.

Answer
void swap(int a, int b)   {
    a = a + b;
    b = a - b;
    a = a - b;
}