Program to swapping two value by using third variable and without using thirdin c-language
Method-1
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter two values a\n");
scanf("%d",&a);
printf("Enter two values b\n");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("Swapping values\na=%d\nb=%d",a,b);
}
Method-2
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter two values a\n");
scanf("%d",&a);
printf("Enter two values b\n");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("Swapping values\na=%d\nb=%d",a,b);
}
OUTPUT
Enter the values a
5
Enter the values b
8
Swapping values
a=8
This program is simple program of swapping to number.In coming program it help more like palindrome, Armstrong etc.
If you like this program then you can share it and for any issues you can direct contact with me from
Home Page.
For regular updates you can also follow my site.
Comments
Post a Comment