> ## Documentation Index
> Fetch the complete documentation index at: https://learn.acadlink.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Swap Using Pointers

> Swap two variables using pointers passed to a function.

## Problem Statement

Write a C program with a function that swaps two variables using pointers.

## Solution

```c theme={null}
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main() {
    int a = 5, b = 10;
    swap(&a, &b);
    printf("a = %d, b = %d\n", a, b);
    return 0;
}
```

## Output

```
a = 10, b = 5
```
