Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
swap_bitwise.c
//gcc 5.4.0 #include <stdio.h> /* void swap(int *a, int *b) { int *temp; *temp = *a; *a = *b; *b = *temp; printf("%d %d",*a,*b); } int main(void) { int a = 3, b = 4; swap(&a,&b); return 0; } void swap(int *a, int *b) { *(a+8) = *b; *(b+8) = *a; printf("%d %d",*(a+8),*(b+8)); } int main(void) { int a = 3, b = 4; swap(&a,&b); return 0; } */ // without using 3rd variable and arithmetic operators void swap(int *a, int *b) { *a = *a ^ *b; *b = *a ^ *b; *a = *a ^ *b; printf("%d %d",*a,*b); } int main(void) { int a = 3, b = 4; swap(&a,&b); return 0; }
run
|
edit
|
history
|
help
1
EUCLIDES BIEN
Area of a rectangular prism
Practice flipping the stars
WHY_?
Project 3 Part 1 v1.75
printing float 3 pointers
bitwise manipulation
3468
Multiple If statements v.09
Taco practice