C Program to Swap Two Numbers
//C Program to Swap Two Numbers
//Header Files
#include<stdio.h>
#include<conio.h>
void main()
{
int n1, n2, temp;
clrscr();
printf("Enter first number: ");
scanf("%d", &n1);
printf("Enter second number: ");
scanf("%d",&n2);
// 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);
getch();
}
Output