From a6557a369b6f0eabad5142f3259ac5bdb09d0696 Mon Sep 17 00:00:00 2001 From: rishikasoni67 <53947523+rishikasoni67@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:33:37 +0530 Subject: [PATCH 1/2] Add files via upload --- swap using 3rd variable.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 swap using 3rd variable.cpp diff --git a/swap using 3rd variable.cpp b/swap using 3rd variable.cpp new file mode 100644 index 0000000..37ec3da --- /dev/null +++ b/swap using 3rd variable.cpp @@ -0,0 +1,16 @@ +// Swappint two numbers using third variable + +#include +int main () + +{ + int a,b,x; + printf("enter the value of a and b="); + scanf("%d%d",&a,&b); + x=a; + a=b; + b=x; + printf("values after swapping are a=%d\nand b=%d",a,b); + return 0; + +} From 532ee760da2ae19cee7be57e5fd1f18f05972fbe Mon Sep 17 00:00:00 2001 From: rishikasoni67 <53947523+rishikasoni67@users.noreply.github.com> Date: Thu, 1 Oct 2020 19:39:55 +0530 Subject: [PATCH 2/2] Add files via upload --- swap without using variable.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 swap without using variable.cpp diff --git a/swap without using variable.cpp b/swap without using variable.cpp new file mode 100644 index 0000000..97c78ee --- /dev/null +++ b/swap without using variable.cpp @@ -0,0 +1,15 @@ +// Swapping without using third variable + +#include +int main() + +{ + int a,b; + printf("enter the values of a and b = "); + scanf("%d%d",&a,&b); + a=a+b; + b=a-b; + a=a-b; + printf("values after swapping are a=%d \n b=%d",a,b); + return 0; +}