#include <stdio.h>
#include <conio.h>
void swap(int*, int*); /* function declaration using references */
void main()
{
int a, b;
printf("Enter
value for a and b\n");
scanf("%d%d",&a,&b);
printf("Before
Swapping\na = %d\nb = %d\n", a, b);
swap(&a, &b); /*
function call */
printf("After
Swapping\na = %d\nb = %d\n", a, b);
getch();
}
void swap(int *x, int *y) /* function definition */
{
int temp;
temp = *y;
*y = *x;
*x = temp;
}
0 yorum:
Yorum Gönder