Swapping using third variable in c and c++ and any language use logic.
Swapping using third variable in c,c++,java and any language use logic.......
// swapping using third variable.
#include<stdio.h>
#include<conio.h>
void main(){
int a,b,c;
clrscr();
printf("Enter the value of a=\t");
scanf("%d",&a);
printf("Enter the value of b=\t");
scanf("%d",&b);
printf("before swapping\n");
printf("a is=%d",a);
printf("\nb is=%d\n",b);
c=a;
a=b;
b=c;
printf("after swapping\n");
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}
Divanshu Sindhwani
// swapping using third variable.
#include<stdio.h>
#include<conio.h>
void main(){
int a,b,c;
clrscr();
printf("Enter the value of a=\t");
scanf("%d",&a);
printf("Enter the value of b=\t");
scanf("%d",&b);
printf("before swapping\n");
printf("a is=%d",a);
printf("\nb is=%d\n",b);
c=a;
a=b;
b=c;
printf("after swapping\n");
printf("a is=%d\n",a);
printf("b is=%d",b);
getch();
}
Divanshu Sindhwani
Comments
Post a Comment