Shell Program For Swap Two Numbers

  • Post author:
  • Post category:Linux
  • Post comments:2 Comments
  • Reading time:1 mins read

Swapping two number using a Shell Program. I tried this in Ubuntu Linux. Saved with the extension of .sh, and i run this program by using sh <filename>. Lets try out and tell any query if there.

Note : Refer How To Copy The Following Code From This Site:

 

  • Content Stoling is prevented on this site.
  • So Refer the Link to copy the below coding part by using this >>> link <<< 

 

[sourcecode language=’css’]
echo “SWAP TWO NUMBERS USING TWO VARIABLES”
echo “Enter the value of two numbers”
read a
read b
echo “Enter the value of two numbers”
echo “a=$a , b=$b”
a=$ [ $a + $b ]
b=$ [ $a – $b ]
a=$ [ $a – $b ]
echo “After swapping the values are:”
echo “a=$a , b=$b”
[/sourcecode]
Output:

SWAP TWO NUMBERS USING TWO VARIABLES

Enter the value of two numbers
a=5
b=10
After swapping the values are:
a=10
b=5

Balaji

, is a computer science graduate. He is interested in sharing the system tweaking ,Web-designing, SEO and tips to use your system fetching you utmost use. Happy tweaking! :D

This Post Has 2 Comments

  1. cheap desinger handbags

    Thanks Balaji for sharing these useful and best suggestions with us. keeep up the right and great work. thanks again for taking time to write such useful posts.

    1. shretali

      Thanks ! for easy logic.

Leave a Reply