Answers for "swap in arr with pointer c++"

C
1

swap using pointers c++

#include <stdio.h>

void swap(int *x,int *y){
	int t=*x;
	*x=*y;
	*y=t;
}

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
    printf("Before Swap : %d %d",a,b);
	swap(&a,&b);
    
	printf("After Swap : %d %d",a,b);
}
Posted by: Guest on July-12-2021

Code answers related to "C"

Browse Popular Code Answers by Language