google-site-verification: googlef8aa845b858144d3.html COMPUTER SCIENCE NOTES: Swapping: (Example 5) Swapping of two numbers using call by reference

Thursday, March 2, 2017

Swapping: (Example 5) Swapping of two numbers using call by reference

/* 5 program of swap 2 number */
#include<stdio.h>
#include<conio.h>
void swap(int *,int *);
void exchange(int **, int *);
void main()
{
int c,d;
clrscr();
printf("Enter the value of c and d:\n");
scanf("%d %d",&c,&d);
swap(&c,&d);
printf("value of c=%d \nvalue of d=%d",c,d);
getch();

}
void swap(int *cc, int *dd)
{
exchange(&cc,dd);
}
void exchange(int **cc, int *dd)
{
int t;
t=**cc;
**cc=*dd;
*dd=t;
}

No comments:

Post a Comment