HOME

Saturday, March 14, 2015

C PROGRAM TO SWAP THE NUMBER USING CALL BY REFERENCE

#include<stdio.h>
#include<conio.h>
void swap(int *a,int *b)
{
    int c;
    c=*a;
    *a=*b;
    *b=c;
    printf("a=%d\n",*a);
    printf("b=%d\n",*b);
}
void main()
{
    int a,b;
  printf("enter the two number\n");
  scanf("%d%d",&a,&b);
    printf("without swapping\n");
    printf("a=%d\n",a);
    printf("b=%d\n",b);
    printf("after swapping\n");
    swap(&a,&b);
}