Practice Swapping values Write a function swap int a int b
Practice - Swapping values
Write a function \"swap (int a, int b)\" that exchanges the values of these two variables. Make sure this function is thread-safe (i.e. make sure no race conditions can occur).Solution
Answer :-
#include <stdio.h>
 
 void swap(int*, int*);
 
 int main()
 {
 int x, y ;
 
 printf(\"Enter the value of x \ \") ;
 scanf(\"%d\",&x) ;
printf(\"Enter the value of y\ \") ;
 scanf(\"%d\",&y) ;
 
 swap(&x, &y) ;
 
 printf(\"After Swapping\ x = %d\ y = %d\ \", x, y) ;
 
 return 0 ;
 }
 
 void swap(int *a, int *b)
 {
 int temp;
    temp = *b;
 *b = *a;
 *a = temp;   
 }

