C program to swap 2 numbers

Previous
Next
#include <stdio.h>
int main()
{
	int x, y, temp;
	
	printf("Enter two numbers: ");
	scanf("%d%d", &x, &y);
	
	printf("Before swap = %d , %d\n", x, y);
	temp=x;
	x=y;
	y=temp;
	printf("After swap = %d , %d\n", x, y);
	return 0;
}
Previous
Next

Add Comment

Courses Enquiry Form