#include<stdio.h>
#include<conio.h>
void swap(int*,int*);
void main()
{
int a,b;
clrscr();
printf("enter first number :");
scanf("%d",&a);
printf("enter second number :");
scanf("%d",&b);
clrscr();
printf("Before swapping\n\t\ta=%d\n\n\t\tb=%d",a,b);
swap(&a,&b);
printf("\n\nAfter swapping\n\t\ta=%d\n\n\t\tb=%d",a,b);
getch();
}
void swap(int *x,int *y)
{
int z;
z=*y;
*y=*x;
*x=z;
}
#include<conio.h>
void swap(int*,int*);
void main()
{
int a,b;
clrscr();
printf("enter first number :");
scanf("%d",&a);
printf("enter second number :");
scanf("%d",&b);
clrscr();
printf("Before swapping\n\t\ta=%d\n\n\t\tb=%d",a,b);
swap(&a,&b);
printf("\n\nAfter swapping\n\t\ta=%d\n\n\t\tb=%d",a,b);
getch();
}
void swap(int *x,int *y)
{
int z;
z=*y;
*y=*x;
*x=z;
}
Comments
Post a Comment