SWAPPING OF VALUES
(Using 3rd Variable)
To
write a Shell Program to swap two values using 3rd variable.
ALGORITHM:
Step 1: Read the Values of ‘a’ and ‘b’
Step 2: Swap the values of ‘a’ to the third variable
‘temp’
Step 3: Swap the value of ‘b’ to ‘a’ and ‘b’ to ‘temp’
Step 4: Print the swapped values of ‘a’ and ‘b’
Step 5: Stop.
SHELL
PROGRAM:
echo "Enter Two Numbers"
read a b
temp=$a
a=$b
b=$temp
echo $a $b
SAMPLE
OUTPUT:
Enter Two Numbers
12 10
10 12
RESULT:
Thus
the program to swap two values using 3rd variable was executed and
the output was verified.
No comments:
Post a Comment