c program to swap two numbers using third variable
>> Monday, October 31, 2011
Hello! This program is very important as it is mostly taught and asked in external, vivas and some time in
campus recruitment exams also. We are Swapping the value of variable 'a' and 'b' by using a third variable 'temp'. Lets look on this program that how it is done.
Output :
Read more...
campus recruitment exams also. We are Swapping the value of variable 'a' and 'b' by using a third variable 'temp'. Lets look on this program that how it is done.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,temp;
printf("enter two values\n");
printf("\na = ");
scanf("%d",&a);
printf("\nb = ");
scanf("%d",&b);
temp=a;
a=b;
b=temp;
printf("\na = %d\tb = %d ", a, b);
getch();
}
Output :
C program to swap two number using third varaible |