Sunday, 28 July 2013

Program to swap two number using function.


#include<stdio.h>
#include<conio.h>

void swape(int *a,int *b);

void main()
{
 int *a,*b;

 clrscr();

 printf("Enter no a and b : ");
 scanf("%d %d",&a,&b);

 printf("Before swap, A : %d B: %d",a,b);

 swape(&a,&b);

 printf("\nAfter swap,  A : %d B: %d",a,b);

 getch();
}

void swape(int *x,int *y)
{
 int *temp;

 *temp=*x;
 *x=*y;
 *y=*temp;
}


Output :


No comments:

Post a Comment