C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C Program to swap two numbers without third variableWe can swap two numbers without using third variable. There are two common ways to swap two numbers without using third variable:
Program 1: Using + and -Let's see a simple c example to swap two numbers without using third variable. #include Output: Before swap a=10 b=20 After swap a=20 b=10 Program 2: Using * and /Let's see another example to swap two numbers using * and /. #include Output: Before swap a=10 b=20 After swap a=20 b=10 |