Swap Variables with Pointers
CSC-115 · Semester I · C Programming
#include <stdio.h> void swap(int *x, int *y) { int temp = *x; *x = *y; *y = temp; } int main() { int a = 10, b = 20; printf("Before: a = %d, b = %d\n", a, b); swap(&a, &b); printf("After: a = %d, b = %d\n", a, b); return 0; }
Write some code, then press Run. Stdout and errors appear here.