C Program to Swap two numbers using third variable

Description

Get two integers a and b from user and swap the values
Sample Input 1:
6 5
Sample Output 1:
5 6

Solution

#include<stdio.h>

int main()

{
    
	int a,b,t;
	printf("Enter a:");
	scanf("%d",&a);

	printf("Enter b:");
	scanf("%d",&b);

	t=a;
	a=b;
	b=t;
	printf("\nAfter Swap\na:%d b:%d",a,b);  
	return 0;

}

Explanation

Get a and b using scanf statement

swap the values using third variable t.

Print a and b using printf statement