From eff0950336947c479fe71932c34bab3c8eeb7f6d Mon Sep 17 00:00:00 2001 From: Pyrocrate <116565353+Pyrocrate@users.noreply.github.com> Date: Mon, 24 Oct 2022 22:41:02 +0530 Subject: [PATCH] Create Swap.c --- Swap.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Swap.c diff --git a/Swap.c b/Swap.c new file mode 100644 index 0000000..0beaf37 --- /dev/null +++ b/Swap.c @@ -0,0 +1,25 @@ +#include +using namespace std; +void swapvalue(int *a, int *b) +{ + int temp; + temp = *a; + *a = *b; + *b = temp; +} +int main() +{ + int x,y; + cout << "Enter the two values\n"; + cin >> x >> y; + int *a, *b; + a = &x; + b = &y; + cout << "Values before swapping\n"; + cout << "a " << *a << '\n'; + cout << "b " << *b << '\n'; + swapvalue(a, b); + cout << "Values after swapping\n"; + cout << "a " << *a << '\n'; + cout << "b " << *b << '\n'; +}