C-programming - Swapping using temporary variable, C program to swap using temporary varible
Swapping using temporary variable
This program uses a temporary variable 'temp' to swap two values.
#include<stdio.h>
#include<conio.h>
int swap(int x,int y);
int main()
{
int a,b;
printf("enter the values");
scanf("%d%d",&a,&b);
swap(a,b);
getch();
}
int swap(int x,int y)
{
int temp;
temp=x;
x=y;
y=temp;
printf("after swapping the values are %d %d",x,y);
}
output
enter the values 2 4 after swapping values are 4 2
The topic on C-programming - Swapping using temporary variable is posted by - Math
Hope you have enjoyed, C-programming - Swapping using temporary variableThanks for your time