Skip to content

Instantly share code, notes, and snippets.

@edenizk
Created May 11, 2018 17:12
Show Gist options
  • Select an option

  • Save edenizk/4c320e6603bf814e387192c050cbc181 to your computer and use it in GitHub Desktop.

Select an option

Save edenizk/4c320e6603bf814e387192c050cbc181 to your computer and use it in GitHub Desktop.
Swap in C
#include <stdio.h>
void swap(float *p1,float *p2){
float tmp;
tmp=*p1;
*p1=*p2;
*p2=tmp;
printf("p1=%f , p2=%f\n",p1,p2);
}
int main(){
float f1=2.5,f2=8.1;
swap(&f1,&f2);
printf("f1=%f, f2=%f\n",f1,f2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment