C program | swap two number using pointer using code | function swap
#include<stdio.h>
void swap(int*,int*);
void main()
{
int a,b;
clrscr();
printf("\nEnter 2 Numbers:");
scanf("%d%d",&a,&b);
printf("\nValues After Swaping.");
swap(&a,&b);
printf("\n a=%d b=%d",a,b);
}
void swap(int*x,int*y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
#include<stdio.h>
void swap(int*,int*);
void main()
{
int a,b;
clrscr();
printf("\nEnter 2 Numbers:");
scanf("%d%d",&a,&b);
printf("\nValues After Swaping.");
swap(&a,&b);
printf("\n a=%d b=%d",a,b);
}
void swap(int*x,int*y)
{
int temp;
temp=*x;
*x=*y;
*y=temp;
}
0 comments: