Program to swapping two value by using third variable and without using thirdin c-language

  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

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language