Swapping by using 2 variables - C Programming

Posted on:
tags: , , , ,

This program is about swapping any two numbers by using 2 variables....
void main(){
int a,b;
printf("enter the number a and b :");

a=a+b;//step 1
printf("after step 1: a=%d\n\n",a);
b=a-b;//step 2
printf("after step 2: b=%d\n\n",b);
a=a-b;//step 3
printf("after step 3: a=%d\n\n",a);

printf("final swapping: \na=%d \nb=%d",a,b);


if you have any query regarding the program then free to ask at youthtalentauzzar@gmail.com

No comments:

Post a Comment

< >