C Program to Swap two Numbers using temperory variable
#include<stdio.h> int main() { double first, second, temp; printf("Enter first number: "); scanf("%lf", &first); printf("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) is assigned to second second = temp; // %.2lf displays number up to 2 decimal points printf("\nAfter swapping, first number = %.2lf\n", first); printf("After swapping, second number = %.2lf", second); return 0; } Output Enter first number: 1.20 Enter second number: 2.45 After swapping, first number = 2.45 After swapping, second number = 1.20