In this answer, We have share how to write a c program to swap two numbers. Copy the below c program and execute it to see the real time program output.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#include <stdio.h> int main() { int x, y; printf("Enter Value of x "); scanf("%d", &x); printf("\nEnter Value of y "); scanf("%d", &y); int temp = x; x = y; y = temp; printf("\nAfter Swapping: x = %d, y = %d", x, y); return 0; } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.