Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Created March 31, 2019 12:10
Show Gist options
  • Save jatinsharrma/2f6c5d62d27c6d77130d530b876ee18a to your computer and use it in GitHub Desktop.
Save jatinsharrma/2f6c5d62d27c6d77130d530b876ee18a to your computer and use it in GitHub Desktop.
Swapping two numbers - call by refernce
#include <stdio.h>
int swap(int* a, int* b){
int temp;
temp = *a;
*a = *b;
*b = temp;
}
void main(){
int a=2,b=4;
swap(&a,&b);
printf("%d %d",a,b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment