• Wednesday, May 1, 2013

    Swapping two variable in C Programming

    Syed Masoom Rizvi
     A program to swap the value of two variable without using third variable. 


    #include <stdio.h>  
    #include <conio.h> 
    void main(){
    int a,b; // Defining two variables.
    printf("Enter the value of a, b"); //Printing the statement.
    scanf("%d%d",&a,&b); //Getting the value of a,b from user.
    a=a+b;
    b=a-b;
    a=a-b;
    printf("The value of a: %d\nThe value of b: %d"); //Printing the swap value.
    getch();
    }