Write a Program in C to Swap Number Without Using Temporary Variables

 #include <stdio.h>

int main()
{
    double firstNumber, secondNumber;
    printf("Enter first number: ");
    scanf("%lf", &firstNumber);

    printf("Enter second number: ");
    scanf("%lf",&secondNumber);
    // Swapping process
    firstNumber = firstNumber - secondNumber;
    secondNumber = firstNumber + secondNumber;
    firstNumber = secondNumber - firstNumber;
    printf("After swapping, firstNumber = %.2lf ", firstNumber);
    printf("After swapping, secondNumber = %.2lf", secondNumber);
    return 0;
}

Output

Enter first number: 50.15
Enter second number: -1.5
After swapping, firstNumber = -1.5
After swapping, secondNumber = 50.15

Explanation

In this Program ,we have interchange the value of variable without using third variable.