C program to swap two numbers with using third variable, Swapping means to interchange of two numbers. In this program to Swapping two numbers without using third variables And Also use Call by Reference Functions.
Swapping of two With Using Third Variable numbers in C program codes
#include<stdio.h>
#include<conio.h>
void swap(*int,*int);
void main()
{
int a, b;
clrscr();
printf("\n Enter the two values of a And b ");
scanf("%d%d",&a, &b);
swap(&a,&b);
printf("\n After Swapping a = %d\t, b = %d",a,b);
getch();
}
void swap(int *a,int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
Output:-

Swapping of two With Using Third Variable numbers in C program codes
#include<stdio.h>
#include<conio.h>
void swap(*int,*int);
void main()
{
int a, b;
clrscr();
printf("\n Enter the two values of a And b ");
scanf("%d%d",&a, &b);
swap(&a,&b);
printf("\n After Swapping a = %d\t, b = %d",a,b);
getch();
}
void swap(int *a,int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;
}
Output:-
