C program to swap 2 numbers using 2 variables.
/* C program to swap values*/
#include<stdio.h>
int main()
{
int firstNo = 2, secondNo = 4;
firstNo = firstNo + secondNo;
secondNo = firstNo - secondNo;
firstNo = firstNo - secondNo;
//Value of firstNo and secondNo swapped
printf("fisrtNo=%d",firstNo);
printf("\nsecondNo=%d",secondNo);
return 0;
}
Output:
fisrtNo=4 secondNo=2
Post a Comment
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.