Hello friends!!!!!

Swapping of two number using call by reference

11/16/20241 min read

#include<stdio.h>

void swap(int *a , int *b){

int temp;

temp = *a;

*a = *b;

*b = temp;

}

int main() {

int x = 10 , y = 20;

printf("Before swapping - a = %d and b = %d\n", x, y);

swap(&x , &y);

printf("After swapping - a = %d and b = %d", x, y);

}

Output:

Before swapping - a = 10 and b = 20

After swapping - a = 20 and b = 10