HOME

Monday, March 23, 2015

C PROGRAM TO SWAP THE NUMBER USING POINTER

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b,*x,*y;
    printf("a=");
    scanf("%d",&a);
    printf("\nb=");
    scanf("%d",&b);
    x=&a;
    y=&b;
    *x=*x+*y;
    *y=*x-*y;
    *x=*x-*y;
    printf("after swapping\n");
    printf("a=%d",*x);
    printf("\na=%d",*y);
}

No comments:

Post a Comment