C Program To Swap Two Number Using Function

C Program :

/* Aim: Write a function for the following function prototype
void Swap(int a,int */

#include<stdio.h>

void Swap(int a,int b); // Swap Function Prototype

void main()
{
	int a,b;
	printf("\n Enter Values of a and b:- ");
	scanf("%d%d",&a,&b);
	printf("\n Values before swapping a=%d and b=%d \n",a,b); 
	Swap(a,b);
}

// Swap Function
void Swap(int a,int b)
{
	int temp;

	temp=a;
	a=b;
	b=temp;
 
	printf("\n Values after swapping a=%d and b=%d \n \n",a,b);
  
} // End of the code 


/* Output of above code:-

[root@localhost ~]# cc swap.c
[root@localhost ~]# ./a.out

 Enter Values of a and b:- 4 2

 Values before swapping a=4 and b=2 

 Values after swapping a=2 and b=4 */