Wednesday, July 6, 2022
HomeUncategorizedSwap two Number Without using third Variable or number

Swap two Number Without using third Variable or number

#include

int main()
{ int a,b;
printf(“please enter first number:”);
scanf(“%d”,&a);
printf(“please enter Second number:”);
scanf(“%d”,&b);
printf(“nn”);
printf(“Number before swapping:n”);
printf(“a=%dn”,a);
printf(“b=%dn”,b);
//swap number
a=a+b;
b=a-b;
a=a-b;
printf(“nn”);//used for new line
printf(“Number after swapping:n”);
printf(“First Number a=%dn”,a);
printf(“Second Number b=%dn”,b);
printf(“nn”);
   
    return 0;
    }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

CSAT FORMULA BOOK

Only IAS Current Affairs

What is a Polynomial?