From d9f40ae8035bba705b60006d292c1637c07424e8 Mon Sep 17 00:00:00 2001 From: SunnyChaturvedi <43118715+SunnyChaturvedi@users.noreply.github.com> Date: Tue, 2 Oct 2018 20:46:19 +0530 Subject: [PATCH] cpp for hac2ber --- cpp file for hac2ber | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 cpp file for hac2ber diff --git a/cpp file for hac2ber b/cpp file for hac2ber new file mode 100644 index 0000000..c4703e6 --- /dev/null +++ b/cpp file for hac2ber @@ -0,0 +1,31 @@ +#include +using namespace std; + +void cyclicSwap(int *a, int *b, int *c); + +int main() +{ + int a, b, c; + + cout << "Enter value of a, b and c respectively: "; + cin >> a >> b >> c; + + cout << "Value before swapping: " << endl; + cout << "a, b and c respectively are: " << a << ", " << b << ", " << c << endl; + + cyclicSwap(&a, &b, &c); + + cout << "Value after swapping numbers in cycle: " << endl; + cout << "a, b and c respectively are: " << a << ", " << b << ", " << c << endl; + + return 0; +} + +void cyclicSwap(int *a, int *b, int *c) +{ + int temp; + temp = *b; + *b = *a; + *a = *c; + *c = temp; +}