Swipe Two Variable without Using third Variable

-- Leave a Comment
Hello Here is a C program to Swipe a Two Variables With out the use of other verifiable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<stdio.h>
void main()
    {
    int a,b;
    printf ("Enter the value of A:- ");
    scanf ("%d",&a);
    printf ("Enter the value of B:- ");
    scanf ("%d",&b);
    printf("%d is A and %d is B\n",a,b);
    a=a+b;
    b=a-b;
    a=a-b;
    printf("%d is A and %d is B\n",a,b);
    }

Let 4(a) 6(b)
4(a) + 6(b) = 10(a New)
10(a New) - 6(b) = 4(b New)
10(a New) - 4(b New) = 6(a New)

I expect you understand the code above.

Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University. I know something about Linux, Android, Java, Nodejs, Unity3D and 3 dots :)

0 comments:

Post a Comment