Welcome To Grey Shield

Website is under Maintenance

C Program To Swap Two Numbers using Third Variable

 C Program To Swap Two Numbers using Third Variable


#include<stdio.h>

int main()

{

//take two numbers a and b for swapping

int a, b;

int temp;

printf("Enter value of a: ");

scanf("%d", &a);

printf("Enter the value of b: ");

scanf("%d", &b);


// now swap two variable a and b

temp=a;

a=b;

b=temp;

printf("After swap a = %d amd b = %d", a , b);

return 0;

}






Description:

1. To swap two numbers we will use any third variable to store extra value so that we can change value of a and b.


If you have any doubt, Please let me know

Previous Post Next Post

Contact Form