This C program uses a third variable to swap the values of two input numbers. It prompts the user to enter two integer values, stores them in variables x and y, assigns x's value to a third variable z, assigns y's value to x, then assigns z's original value (which is now x's original value) to y, effectively swapping the values stored in x and y. It then prints the swapped values of x and y.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
45 views
A Program To Swap Two Numbers in C Language
This C program uses a third variable to swap the values of two input numbers. It prompts the user to enter two integer values, stores them in variables x and y, assigns x's value to a third variable z, assigns y's value to x, then assigns z's original value (which is now x's original value) to y, effectively swapping the values stored in x and y. It then prints the swapped values of x and y.