HOME

Thursday, April 23, 2015

C PROGRAM TO SWAP NUMBER BY PASSING POINTER TO FUNCTION

#include<stdio.h>
#include<conio.h>
int swap(int **c,int **d);
void main()
{
    int a,b,*c,*d;
    printf("enter the value\n");
    printf("a=");
    scanf("%d",&a);
    printf("\nb=");
    scanf("%d",&b);
    c=&a;
    d=&b;
    swap(&c,&d);
}
int swap(int **c,int **d)
{
    **c=**c+**d;
    **d=**c-**d;
    **c=**c-**d;
    printf("after swapping\n");
    printf("a=%d",**c);
    printf("\nb=%d",**d);
    return 0;
}

No comments:

Post a Comment