Skip to content

Commit c5c702e

Browse files
Create Swapping Two Numbers
Create program for swapping variable without using third variable
1 parent c5c05c2 commit c5c702e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Swapping Two Numbers

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<stdio.h>
2+
#include<conio.h>
3+
void main()
4+
{
5+
int a;
6+
int b;
7+
printf("Enter First Number");
8+
scanf("%d",&a);
9+
printf("Enter Second Number");
10+
scanf("%d",&b);
11+
printf("Before Swapping");
12+
printf("Value of a is",a);
13+
printf("Value of b is",b);
14+
printf("After Swapping");
15+
a=a+b;
16+
b=a-b;
17+
a=a-b;
18+
printf("Value of a is",a);
19+
printf("Value of b is",b);
20+
return 0;
21+
}

0 commit comments

Comments
 (0)