Program to Swap two numbers using pointers in C
#include<stdio.h>int main()
{
int a, b;
int *swapa, *swapb;
int temp;
printf("Enter First Number here = ");
scanf("%d", &a);
printf("\nEnter Second Number here = ");
scanf("%d", &b);
swapa = &a;
swapb = &b;
temp = *swapa;
*swapa = *swapb;
*swapb = temp;
printf("\nThe values after swapping are: a = %d b = %d\n", a, b);
return 0;
}
Comments
Post a Comment