Skip to content

Commit b9735e2

Browse files
committed
Create swap_mul_div.c
1 parent fb5eaed commit b9735e2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

swap_mul_div.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
Problem Statement: Create a C program to swap two numbers without using a third variable,
3+
using multiplication and division method.
4+
*/
5+
6+
//Enter any two numbers and swap numbers without third number
7+
//n1=10 and n2=20
8+
9+
#include<stdio.h>
10+
11+
int main() {
12+
int a, b;
13+
14+
printf("\nEnter the first number: ");
15+
scanf("%d", &a);
16+
17+
printf("\nEnter the second number: ");
18+
scanf("%d", &b);
19+
20+
printf("\nBefore Swapping: 1st num = %d, 2nd num = %d. \n", a, b);
21+
22+
a = a * b;
23+
b = a / b;
24+
a = a / b;
25+
26+
printf("\nAfter swapping: 1st num = %d, 2nd num = %d. \n\n", a, b);
27+
return 0;
28+
}

0 commit comments

Comments
 (0)