Practical 10.
echo "enter marks of OSY"
read OSY
echo "enter marks of AJP"
read AJP
echo "enter marks of STE"
read STE
if [ $OSY -gt 28 ] && [ $AJP -gt 28 ] && [ $STE -gt 28 ]
then
echo "congrats ! you have passed in all subjects"
elif [ $OSY -lt 28 ] && [ $AJP -lt 28 ] && [ $STE -lt 28 ]
then
echo "you failed in all subject"
elif [ $OSY -lt 28 ] && [ $AJP -lt 28 ] && [ $STE -gt 28 ]
then
echo "you passed in STE"
elif [ $OSY -lt 28 ] && [ $AJP -gt 28 ] && [ $STE -lt 28 ]
then
echo "you passed in AJP"
elif [ $OSY -gt 28 ] && [ $AJP -lt 28 ] && [ $STE -lt 28 ]
then
echo "you passed in OSY"
elif [ $OSY -lt 28 ] && [ $AJP -gt 28 ] && [ $STE -gt 28 ]
then
echo "you passed in AJP and STE"
elif [ $OSY -gt 28 ] && [ $AJP -lt 28 ] && [ $STE -gt 28 ]
then
echo "you passed in OSY and STE"
elif [ $OSY -lt 28 ] && [ $AJP -lt 28 ] && [ $STE -lt 28 ]
then
echo "you failed in all subject"
elif [ $OSY -gt 28 ] && [ $AJP -gt 28 ] && [ $STE -lt 28 ]
then
echo "you have passed in OSY and AJP"
fi
Output:
enter marks of OSY
22
enter marks of AJP
33
enter marks of STE
44
you passed in AJP and STE
Practical 10.2
echo "Enter the first number:"
read v1
echo "Enter the second number:"
read v2
echo "Enter the third number:"
read v3
if [ $v1 -gt $v2 ] && [ $v1 -ge $v3 ]
then
echo "$v1 is greater"
elif [ $v2 -gt $v1 ] && [ $v2 -ge $v3 ]
then
echo "$v2 is greater"
else
echo "$v3 is greater"
fi
Output:
Enter the first number:
Enter the second number:
Enter the third number:
4 is greater
Practical 10.3
echo "Enter your name:"
read v1
echo "Your name is: $v1"
Output:
Enter your name:
Sahil
Your name is Sahil
Practical 10.4
echo "enter first number"
read num1
echo "enter second number"
read num2
if[num1 -gt num2]
then
echo "first is greater"
fi
Output:
Enter first number
10
Enter second number
First is greater