Interchange the contents of two variables using a function.

#include <stdio.h>

void swap(int, int);

int main(void)
{
int a, b;

printf("\nEnter values for a, b : ");
scanf("%d%d", &a, &b);

printf( "\nBefore swapping a = %d b = %d", a, b);
swap(a, b);
printf( "\nAfter swapping a = %d b = %d", a, b);

return 0;
}

void swap(int c, int d)
{
int x;

x = c;
c = d;
d = x;
}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin