C Program to Swap Two Numbers
In this program I have discussed about the C Program to Swap Two Numbers .
We have used a third variable here to swap the two numbers.
Swap means to interchange the values of two variables.
---------------------------------------------------------------------------------------------
#include<stdio.h>
void main()
{ int a,b,c;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("The first number %d \n",a);
printf(" The second number %d ",b);
}
----------------------------------------------------------------------------------------------
If you want the C program to swap two numbers without using third variable then click here.
Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.
Enjoy programming in C.
0 comments:
Post a Comment