C Online Compiler
Example: Swap Two Numbers Without using Third Variable in C language
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Swap Two Numbers Without using Third Variable in C language #include <stdio.h> int main() { double p, q; printf("----Enter the two integer or real numbers----\n"); scanf("%lf %lf", &p, &q); p = p - q; q = p + q; p = q - p; printf("After swapping, p = %.2lf\n", p); printf("After swapping, q = %.2lf\n", q); return 0; }
10 7
Output
Clear
ADVERTISEMENTS