Important C Programs

C Program to Swap Two Numbers

//C Program to Swap Two Numbers
//Header Files

void main()

int n1, n2, temp;

printf("Enter first number: ");
scanf("%d", &n1);

printf("Enter second number: ");

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

// Value of n2 is assigned to n1
n1 = n2;

// Value of temp (which contains the initial value of n1) is assigned to n2
n2 = temp;

printf("\nAfter swapping, firstNumber = %d\n", n1);
printf("After swapping, secondNumber = %d", n2);



You can also see a video how to run this program