Sunday, July 31, 2016

Swapping Program Through Pointer- Call By Reference

Swapping Program Through Pointer- Call By Reference


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
void swap(int *x,int *y);


clrscr();
printf("Enter YourTwo Values for Swaping::");
printf("\nEnter Your 1st No.::");
scanf("%d",&a);
printf("Enter Your 2nd No.::");
scanf("%d",&b);
swap(&a,&b);


getch();
}
void swap( int *x,int *y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
printf("\n\n Call By Refrance\n\n");


printf("The swaped values are \n a=%d \n b=%d",*x,*y);
}


/*
Output~


Enter YourTwo Values for Swaping::
Enter Your 1st No.::23
Enter Your 2nd No.::34

Call By Refrance

The swaped values are
a=34
b=23

*/

No comments:

Post a Comment