Custom Search

Monday, 3 September 2012

Write a linux Shell Script to swap two numbers without using third variable, Swapping in shell script


Write a linux Shell Script to swap two numbers without using third variable, Swapping in shell script


Program
echo "please enter first number"
read a
echo " please enter second number"
read b
echo " value of a before swapping is $a and value of b before swapping is $b"

#swapping
a=$((a+b))
b=$((a - b))
a=$((a-b))

echo "value of a after swapping is $a and value of b after swapping is $b"

No comments:

Post a Comment

Laptops