0% found this document useful (0 votes)
52 views

Lab Assignment

The document describes a shell script that swaps the values of two variables. It prompts the user to enter values for variables a and b, then uses a third temporary variable t to swap the values. The swapped values of a and b are then printed. The document also lists additional shell script exercises for temperature conversion, circle calculations, and interest calculation.

Uploaded by

sansayana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Lab Assignment

The document describes a shell script that swaps the values of two variables. It prompts the user to enter values for variables a and b, then uses a third temporary variable t to swap the values. The swapped values of a and b are then printed. The document also lists additional shell script exercises for temperature conversion, circle calculations, and interest calculation.

Uploaded by

sansayana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exercise 6: Shell Programming

Example:
6.ASwapping values of two variables
Aim
Tools Required:
1. VI Editor
2. Shell
Algorithm
Step 1 :
Start
Step 2 :
Read the values of a and b
Step 3 :
Interchange the values of a and b using another variable t as follows:
t=a
a=b
b=t
Step 4 :
Print a and b
Step 5 :
Stop
Program (swap.sh)
# Swapping values
echo -n "Enter value for A : "
read a
echo -n "Enter value for B : "
read b
t=$a
a=$b
b=$t
echo "Values after Swapping"
echo "A Value is $a"
echo "B Value is $b"
Output
[san@localhost simple]$ sh swap.sh
Enter value for A : 12
Enter value for B : 23
Values after Swapping
A Value is 23
B Value is 12

Exercises
=======
6.BFahrenheit to Centigrade Conversion
6.C Area & Circumference of Circle
6.D Simple Interest Calculation
==================================END==============================

You might also like