maximum two number and three number
EX.NO:3.d MAXIMUM OF TWONUMBERS
Aim:
To write a shell program to find greatest of
two numbers.
Algorithm:
Step1: Declare the two
variables.
Step2: Check if A is
greater than B.
Step3: If so print A is
greater.
Step4: Else B is
greater
.
Programcode:
clear
echo " enter two no"
Read a
read b
if [ $a -gt $b ]
then
echo "$a is greater"
else
echo "$b is greater"
fi
Sample I/P:
Enter two no
5
6
Sample
O/P:
b is
greater
Result:
Thus
the shell program to find the maximum of three numbers is executed and output
is verified successfully.
VIVA-VOCE QUESTIONS:
1. What is read
command?
2. Write
syntax of if function.
3. What is the use of clear command?
4.What
is "-gt" in shell script?
EX.NO:3.eMAXIMUM
OF THREENUMBERS
Aim:
To write a shell program to find greatest of threenumbers.
Algorithm:
Step1: Declare
the three variables.
Step2: Check if
A is greater than B andC.
Step3: If so
print Aisgreater.
Step4: Else
check if B is greater thanC.
Step5: If so print B isgreater.
Step6: Else
print C isgreater.
Programcode:
echo " Enter
A:"
reada
echo " Enter
B:"
readb
echo " Enter
C:"
readc
if [ $a -gt $b
-a $a -gt $c ]
then
echo "A is
greater"
elif [ $b -gt $a
-a $b -gt $c ]
then
echo "B is
greater"
else
echo "C is
greater"
fi
Sample I/P:
Enter A:23 Enter
B:45 Enter C:67
Sample O/P:
C is greater
Result:
Thus the shell program to find the maximum of three numbers is
executed and output is verified successfully.
VIVA-VOCE QUESTIONS:
1. What is read
command?
2. Write
syntax of if function.
3. What is the use of clear command?
4. What is
“-gt” in shell script?
5.What is “-a”
in shell script
Comments
Post a Comment