Index: S.No Date Topic Sign Remarks
Index: S.No Date Topic Sign Remarks
4. Combination of subjects
a) Addition
read a b
add=`expr $a + $b`
echo $add
b) Subtraction
echo enter two numbers
read a b
sub=`expr $a - $b`
echo $sub
c) Multiplication
read a b
mul=`expr $a \* $b`
echo $mul
d) Division
read a b
div=`expr $a / $b`
echo $div
read a b
if test $a -gt $b
then
else
fi
read a b c
if test $a -gt $b
then
if test $a -gt $c
then
else
fi
then
else
fi
4. Implementation of Combination
echo Combination of subjects in objects:
read n
read r
p=1
q=1
m=1
if test $r -gt $n
then
exit
fi
x=`expr $n - $r`
while [ $n -gt 0 ]
do
p=`expr $p \* $n`
n=`expr $n - 1`
done
while [ $r -gt 0 ]
do
q=`expr $q \* $r`
r=`expr $r - 1`
done
while [ $x -gt 0 ]
do
m=`expr $m \* $x`
x=`expr $x - 1`
done
q=`expr $q \*$m`
c=`expr $p / $q`
read p
read r
read t
x=`echo $r + 1 | bc`
n=1
i=1
while [ $n -le $t ]
do
i=`echo $i \* $x | bc`
n=`echo $n + 1 | bc`
done
i=`echo $i \* $p | bc`
ci=`echo $i - $p | bc`
read a
n=1
while [ $n -le $a ]
do
echo $n
n=`expr $n + 1`
done
read a
b=0
while [ $a -gt 0 ]
do
c=`expr $a % 10`
a=`expr $a / 10`
b=`expr $b + $c`
done
b=`expr $a % 2`
if test $b -eq 0
then
else
fi
read a
x=0
y=1
z=0
echo $x
echo $y
while [ $a -ge $z ]
do
z=`expr $x + $y`
if test $z -ge $a
then
exit
fi
echo $z
x=`expr $y`
y=`expr $z`
done
10.HCF Calculation
read a b
x=1
y=1
if test $a -eq 1
then
echo HCF is 1
exit
then
echo HCF is 1
exit
fi
n=1
f=1
if test $a -lt $b
then
n=$a
x=$a
y=$b
else
n=$b
x=$b
y=$a
fi
while [ $n -ge 2 ]
do
c=`expr $x % $n`
if test $c -eq 0
then
d=`expr $y % $n`
if test $d -eq 0
then
echo HCF is $n
exit
fi
fi
n=`expr $n - 1`
f=0
done
if test $f -eq 0
then
echo HCF is 1
fi
11.LCM Calculation
read a b
n=1
x=1
y=1
r=1
if test $a -eq 1
then
echo LCM is $b
exit
then
echo LCM is $a
exit
fi
if test $a -gt $b
then
x=$a
y=$b
else
x=$b
y=$a
fi
while [ $n -le $x ]
do
r=`expr $x \* $n`
res=`expr $r % $y`
then
echo LCM is $r
exit
fi
n=`expr $n + 1`
done
read a
x=`expr $a % 4`
if test $x -eq 0
then
fi
read a
read b
n=1
x=1
while [ $b -ge $n ]
do
x=`expr $x \* $a`
n=`expr $n + 1`
done
echo
Enter any number
read a
b=`expr $a / 2`
if test $b -eq 1
then
fi
n=2
x=0
while [ $b -ge $n ]
do
c=`expr $a % $n`
if test $c -eq 0
then
x=0
break
else
x=1
fi
n=`expr $n + 1`
done
if test $x -eq 1
then
fi
read a
read b
read c
si=`expr $a \* $b \* $c / 100`
echo Then Simple interest will be $si
echo
Enter two numbers
read x y
if test $x -gt $y
then
x=`expr $x - $y`
y=`expr $x + $y`
x=`expr $y - $x`
else
y=`expr $y - $x`
x=`expr $x + $y`
y=`expr $x - $y`
fi
read a
n=1
while [ $n -lt 11 ]
do
b=`expr $a \* $n`
n=`expr $n + 1`
done
18.String Operations
read a
read b
20.Checking Palindrome
read a
d=`expr $a`
c=0
while [ $d -gt 0 ]
do
b=`expr $d % 10`
d=`expr $d / 10`
c=`expr $c \* 10 + $b`
done
if test $a -eq $c
then
else
fi
read ch
case $ch in
1)
echo "Select the operation you want to perform:"
echo "1. Addition\n2. Subtraction\n3. Multiplication\n4. Divison"
read choice
case $choice in
1)
read -p "Enter 2 numbers: " a b
ans=`expr $a + $b`
echo "The answer is $ans"
;;
2)
read -p "Enter 2 numbers: " a b
ans=`expr $a - $b`
echo "The answer is $ans"
;;
3)
read -p "Enter 2 numbers: " a b
ans=`expr $a \* $b`
echo "The answer is $ans"
;;
4)
read -p "Enter 2 numbers: " a b
ans=`expr $a / $b`
echo "The answer is $ans"
;;
esac
2)
read -p "Enter a 5 digit number: " num
i=0
mod=0
sum=0
if test $i -gt 5
then
echo "Next time please enter a number of 5 digits only."
fi
echo "The answer is: $sum"
3)
read -p "Enter 2 numbers: " a b
if test $a -gt $b
then
echo "$a is greater"
else
echo "$b is greater"
fi
;;
4)
read -p "Enter 3 numbers: " a b c
if test $a -gt $b
then
if test $a -gt $c
then
echo "$a is greatest"
else
echo "$c is greatest"
fi
else
if test $b -gt $c
then
echo "$b is greatest"
else
echo "$c is greatest"
fi
fi
;;
5)
read -p "Enter temperature in degrees celcius: " degc
temp=`expr $degc \* 9`
temp=`expr $temp / 5`
temp=`expr $temp + 32`
temp=`expr $r / 100`
temp=`expr $temp + 1`
temp=`expr $p \* $temp`
temp=`expr $temp - $p`
a=0
b=1
sum=0
echo $a
k=`expr $k - 1`
k=`expr $k - 1`
r2=`expr $num % $k`
if test $r1 -eq 0 || test $r2 -eq 0
then
echo "This is not a prime number."
exit 0
fi
done
echo "This is a prime number."
;;
17)
read -p "Enter the principal amount: " p
read -p "Enter the rate of interest: " r
read -p "Enter the time period: " t
temp=`expr $p \* $r`
temp=`expr $temp \* $t`
temp=`expr $temp / 100`
a=`expr $a + $b`
b=`expr $a - $b`
a=`expr $a - $b`