#include <stdio.h>
void swap(int a,int b);
void _swap(int *a,int *b);
int main() {
int x=3,y=5;
printf("x = %d and y = %d\n",x,y);
swap(x,y);
printf("x = %d and y = %d\n",x,y);
_swap(&x,&y);
return 0;
}
//call by value
void swap(int a,int b){
int t = a;
a=b;
b=t;
printf("a = %d and b = %d\n",a,b);
}
//call by reference
void _swap(int *a, int *b){
int t=*a;
*a=*b;
*b=t;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: