Computer Science, asked by singhrohitkumar98106, 7 months ago

write a program to input two numbers and swap them without using third variable​

Answers

Answered by kumarbulbule
3

Answer:

We can swap two numbers without using third variable. There are two common ways to swap two numbers without using third variable:

By + and -

By * and /

Answered by ayushisingh5
5

Explanation:

  • Program to swap two numbers without third variable
  • #include<stdio.h>
  • (int main)
  • int a=10, b=20;
  • printf("Before swap a=%d b=%d",a,b);
  • a=a+b;//a=30 (10+20)
  • b=a-b;//b=10 (30-20)
  • a=a-b;//a=20 (30-10)
Similar questions