#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);
printf("\nvalues after swapping: %d\t%d",a,b);
getch();
}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
Output:
Enter two nos: 25 62
values before swapping: 25 62
values after swapping: 62 25
#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);
printf("\nvalues after swapping: %d\t%d",a,b);
getch();
}
void swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
}
Output:
Enter two nos: 25 62
values before swapping: 25 62
values after swapping: 62 25
No comments:
Post a Comment