PPS Practical 55

PPS Practical 55
  • Aim: Write a C program to swap the two values using pointers.
  • Code:
    //For turbo C++ remove below comments
    #include <stdio.h>
    //#include<conio.h>
    void main()
    {
        // clrscr();
        int a,b,*x,*y,temp;
        printf("Enter values of a and b : ");
        scanf("%d%d",&a,&b);
        x=&a;
        y=&b;
        temp=*x;
        *x=*y;
        *y=temp;
        printf("After swapping:\na=%d, b=%d",a,b);
        // getch();
    }
  • Output:
    Output of practical 55

Comments