Vision and dreams are the blueprints of soul and achievements.
-Mohammed Ahmed F

Program to swap two numbers using POINTERS


int main(){

    int a,b;
    int *ptra,*ptrb;
    int *temp;

    printf("Enter any two integers: ");

    printf("Before swapping: a = %d, b=%d",a,b);

    ptra = &a;
    ptrb = &b;

     temp = ptra;
    *ptra = *ptrb;
    *ptrb = *temp;

    printf("\nAfter swapping: a = %d, b=%d",a,b);
    return 0;

Enter any two integers: 8
Before swapping: a = 8, b=3
After swapping: a = 3, b=8

Share this

Related Posts

Dear User,

Thank you for your comment. Hope you like this blog. Kindly share us on Social Media so others can be updated.

-Chief Administrative Officer.