Swap the given numbers,swap the numbers, without using third variable,swap the given two variables numbers without using third variable,swap the given two numbers with using third variable,swap without third variable,swap with third variable,swap the two numbers,given two numbers are swap,swap the given two numbers without and with using third variable
Swap the given two variables without third variable
The below program clear about the swapping the two variables without using the third variable.
#include<stdio.h>
main()
{
int a=5,b=10;
a = a+b;
b = a-b;
a =a-b;
printf("After swap the given number %d %d\n",a,b);
}
Output :-
a = 10, b = 5
Swap the given two variables with third variable
This program is clear the swapping the given variables with using the third variable.
#include<stdio.h>
main()
{
int a=20,b=10,temp;
temp = a;
a = b;
b = temp;
printf("After swap the given number %d %d\n",a,b);
}
Output :-
a = 10, b =20
Swap the given two variables without third variable
The below program clear about the swapping the two variables without using the third variable.
#include<stdio.h>
main()
{
int a=5,b=10;
a = a+b;
b = a-b;
a =a-b;
printf("After swap the given number %d %d\n",a,b);
}
Output :-
a = 10, b = 5
Swap the given two variables with third variable
This program is clear the swapping the given variables with using the third variable.
#include<stdio.h>
main()
{
int a=20,b=10,temp;
temp = a;
a = b;
b = temp;
printf("After swap the given number %d %d\n",a,b);
}
Output :-
a = 10, b =20
0 comments:
Post a Comment