Swapping Values using 3rd Variable : C Programming


Code goes like this :

/* Swapping values without using 3rd Variable */
#include<stdio.h>
main()
{
    int a,b;
    printf(" Enter two numbers :");
    scanf("%d %d",&a,&b);
    printf("\n The values of a & b before swapping values is %d & %d",a,b);
    a=a+b;
    b=a-b;
    a=a-b;
    printf("\n The values of a & b after swapping the values is %d & %d",a,b);
       
}

Output with code :
















Used compiler : Dev CPP
Share on Google Plus

About Nepali Xoro

Interested in Information Technology, Spreading Knowledge for Nepalease IT Students."Loves Traveling", Listen Music and Surfing web.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment