Write a c program to swap two numbers using pointers

Write a c program to swap two numbers using pointers. Swapping the numbers ensures that the numbers assigned in the C programming language will be swapped. Pointers are used to swap two numbers in a C program. Swapping the numbers ensures that the numbers assigned in the C programming language will be swapped.

#include<stdio.h>
int main()
{
int a, b;
int *ptra, *ptrb;
int temp;
printf("Enter value for a: ");
scanf("%d", &a);
printf("\n\nEnter value for b: ");
scanf("%d", &b);
printf("\n\nThe values before swapping are: a = %d b = %d", a, b);
ptra = &a; 
ptrb = &b; 
temp = *ptra; 
*ptra = *ptrb; 
*ptrb = temp; 
printf("\n\nThe values after swapping are: a = %d b = %d", a, b);
}

Enter value for a: 4

Enter value for b: 5

The values before swapping are: a = 4 b = 5

The values after swapping are: a = 5 b = 4