Program for swapping || swap two numbers using third variable in c language.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,temp;
clrscr();
printf("enter value of a=");
scanf("%d",&a);
printf("enter value of b=");
scanf("%d",&b);
printf("before swapping value are= %d\t%d",a,b);
temp=a;
a=b;
b=temp;
printf("\n after swapping value are= %d\t%d",a,b);
getch();
}
■》Output->
enter value of a=2
enter value of b=7
before swapping value are= 2 7
after swapping value are = 7 2
Comments
Post a Comment