1.sum of Digits of A 5 Digit Number
1.sum of Digits of A 5 Digit Number
1.sum of Digits of A 5 Digit Number
9.Odd Number
Echo –n "enter first no"
Read n1
Echo –n "enter second no"
Read n2
If [ $n2 –gt $n1]
Then
For ((i=$n1 ; i<=$n2 ; i++))
do
test =$ (($ i %2))
if [$test –ne 0];
then
echo $ i
fi
done
else
echo "$n2 must be greater than $ n1"
fi
10.Prime Number
echo "enter the range"
read n
read n1
echo "prime numbers between $n and $n1 are listed below"
until test $n = $n1
do
i=2
m= 'expr $n/2'
r= 'expr $n%$i'
while [$i –le $m –a $r –ne 0]
do
i = 'expr $ i +1'
r = 'expr $ n % $i
done
if [$r – ne 0]
then
echo "$n"
fi
n = 'expr $n+1'
done
11.Matrix
echo " 4*4 matrix"
for ((i=1; $i<=4; i++))
do
for ((j=1; $j<=4; j++))
echo –n "$j"
done
echo "ok"
done
13.Asecending Order
echo "enter the number"
for n in 0 1 2 3 4
do
read S[n]
done
for ((i=0; i<=4; i++))
do
echo " $[S[$i]]"
done
for ((i=0; i<=4; i++))
do
for ((j=0; j<=4; j++))
do
if [$[S[$i]] – gt $[S[$j]] ]
then
temp = $ [S[$i]]
S[$i] = $[S[$j]]
S[$j] = $ temp
fi
done
done
echo "ascending order is"
for ((i=0; i<=4; i++))
do
echo "$[B[$i]]"
done
14.Searching A Number
y=0
echo "enter the elements of array"
for ((i=0; i<5; i++))
do
read n[$i]
done
echo "enter the no. to be searched"
read x
for ((i=0; i<5; i++))
do
if [$x –eq $[n(i)]]
then
y=$ (($y+1))
fi
done
echo "the no $x is present $ y times"
15.Number Triangle
n=0
echo –n "enter any number"
read n
read s
for ((i=1; i<=r ; i++))
do
for ((s=n; s>$i; s--))
do
echo –n " "
done
for ((j=1; j<=$i; j++))
do
echo –n "$i"
done
echo " "
done