swapping of two numbers in c program

swapping of two numbers in c program first take two numbers and one temporary variable , first number assign into temporary variable and second number assign into first number , temporary variable assign into second number then two numbers is swaped.

first number =10
second number =20
temporary variable
temporary variable = 10 (first number) // assignment operation
first number = 20 (second number) // assignment operation
second number = 10 (temporary variable) // assignment operation
output first number =20
second number =10

   #include <stdio.h>
int main() {
      double first, second, temp;
      printf("Please enter first number: ");
      scanf("%lf", &first);
      printf("Please enter second number: ");
      scanf("%lf", &second);

      // Value of first is assigned to temp
      temp = first;

      // Value of second is assigned to first
      first = second;

      // Value of temp (initial value of first number) is assigned to second
      second = temp;

      printf("\nAfter swapping, first Number = %.2lf\n", first);
      printf("After swapping, second Number = %.2lf", second);
      return 0;


Please enter first number: 40
Please enter second number:20
After swapping, first Number =20
After swapping, second Number = 40