Computer Science, asked by nevya54, 6 months ago

write a program to accept two numbers from the user and swap them ​

Answers

Answered by Anonymous
2

Answer:

C Program to swap two numbers without third variable

1. #include<stdio.h>

2. int main()

3. {

4. int a=10, b=20;

5. printf("Before swap a=%d b=%d",a,b);

6. a=a+b;//a=30 (10+20)

7.b=a-b;//b=10 (30-20)

8. a=a-b;//a=20 (30-10)

Explanation: Hope it helps you

Answered by shrutikhot
0

Answer:

Program to swap two numbers without third variable

1. #include<stdio.h>

2. int main()

3. {

4. int a=10, b=20;

5. printf("Before swap a=%d b=%d",a,b);

6. a=a+b;//a=30 (10+20)

7. b=a-b;//b=10 (30-20)

8. a=a-b;//a=20 (30-10)

hope this will help you....please Mark me as Brainlest....and follow me

Similar questions