click on this link......

LinkGrand.com

Thursday, 12 September 2013

Swapping of two numbers using call by value

#include<stdio.h>
#include<conio.h>
void swap(int,int);
void main()
{
int a,b;
clrscr();
printf("\nEnter two nos: ");
scanf("%d%d",&a,&b);
printf("\nvalues before swapping: %d\t%d",a,b);
swap(a,b);
getch();
}
void swap(int x,int y)
{
int t;
t=x;
x=y;
y=t;
printf("\n values after swapping: %d\t%d",x,y);
}

Output :
Enter two nos: 5 6
values before swapping:  5      6
values after swapping: 6      5

No comments:

Post a Comment