0% found this document useful (0 votes)
7 views2 pages

Assignment 3

Uploaded by

sreejeet17111995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Assignment 3

Uploaded by

sreejeet17111995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment 3

1. Write a shell program to find the given number is even or odd


using if statement.
Script :

echo "Enter a number "


read a
if (( $a%2==0 ))
then
echo "The entered number is even"
fi
if (( $a%2!=0))
then
echo "The entered number is odd"
fi

2. Write a shell program to find the given number is even or odd


using if statement.
Script :

echo "Enter a number"


read a
if (( $a%2==0 ))
then
echo "The number is even"
else
echo "The number is odd"
fi

3. Write a shell program to find grade systems using if-elif-else


statement.

Script :

echo "Enter a mask "


read mask
if (( $mask>85 && $mask<=100 ))
then
echo "Congrats! you scored grade A"
elif (( $mask>60 && $mask <=85 ))
then
echo "You scored grade B+"
elif (( $mask>40 && $mask <=60 ))
then
echo "You scored grade B"
elif (( $mask>30 && $mask <=40 ))
then
echo "You scored grade C"
else
echo "Sorry you fail"
fi

4. Write a shell program to find the person is eligible for voting or


not using nested if statement.
Script :

echo "Enter a number"


read a
if (($a <= 15))
then
if (($a == 10))
then
echo "Play cricket"
else
echo "Play Football"
fi
else
echo "Play Kabaddi"
fi

5. Write a shell program to make calculator using switch case


statement.
Script :

echo "Enter two number "


read a
read b
echo "Enter your choice"
echo "1. Addition"
echo "2. Subtraction"
echo "3. Multiplication"
echo "4. Division"
echo "5. Reminder"
read ch
case $ch in
1) res=`expr $a + $b`;;
2) res=`expr $a - $b`;;
3) res=`expr $a \* $b`;;
4) res=`expr $a / $b`;;
5) res=`expr $a % $b`;;
esac
echo "result : $res"

You might also like