swap : call by reference

PHOTO EMBED

Thu Jun 09 2022 06:14:09 GMT+0000 (Coordinated Universal Time)

Saved by @KanishqJ8

 void addsub(int *x,int *z) {
     int temp;
     temp=*x+*z;
     *x=temp;
     *z=*x-*z;
 } 
 
 int main() { 
     int a,b; 
     printf("enter the value of a: ");
     scanf("%d",&a);
     printf("enter the value of b: ");
     scanf("%d",&b);
     addsub(&a,&b);
     printf("a=%d\n",a); 
     printf("b=%d",b);
     }
content_copyCOPY