Thursday, 21 December 2017

Swap Two Numbers using Pointers

C Program to swap Two numbers using Pointers


#include<stdio.h>
#include<conio.h>
void swap(int*,int*);
int main()
{
int a,b;
printf("Enter Two number: ");
scanf("%d%d",&a,&b);
printf("\nBefore Swap  a:%d b:%d\n",a,b);
swap(&a,&b);
printf("\nAfter Swap  a:%d b:%d\n\n",a,b);
getch();

}
void swap(int *x, int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}



OUTPUT:



No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...