Question: (9 pts) Following function in C is an implementation of swapping two integers. Your task is to implement the same swap function without using the

 (9 pts) Following function in C is an implementation of swapping

(9 pts) Following function in C is an implementation of swapping two integers. Your task is to implement the same swap function without using the additional temporary variable. # include void swap (int *x, int *y) { // passing by reference int temp; // temporary variable temp = *x; *x *y; *y = temp; } } int main() { int a = 5, b = 7; // variables declaration printf("The value of A before swap = %d ", a); printf("The value of B before swap = %d ", b); swap (&a, &b); // calling by reference = printf(" The value of A after swap printf("The value of B after swap %d ", a); %d ", b); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!