Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

swapping of two numbers without using third variable in shell script

#!/bin/bash
echo "enter first number"
read a
echo "enter second number"
read b
echo "a before swapping is $a and b is $b"
#swapping
a=$((a+b))
b=$((a - b))
a=$((a-b))
echo "a after swapping is  $a and b is $b"
Source by technicalworldforyou.blogspot.com #
 
PREVIOUS NEXT
Tagged: #swapping #numbers #variable #shell #script
ADD COMMENT
Topic
Name
6+7 =