echo "Enter the starting number"
read c
echo "Enter the limit number"
read b
s=0
while test $c -le $b
do
s=`expr $c \* $c`
echo "$c * $c
: $s"
c=`expr $c + 1`
done
OUTPUT:
"square" 12L, 168C written
[eceb33@linuxserver eceb33]$ sh square
Enter the starting number
5
Enter the limit number
10
5 * 5 : 25
6 * 6 : 36
7 * 7 : 49
8 * 8 : 64
9 * 9 : 81
10 * 10 : 100
PROGRAM TO
DETERMINE WHETHER THE GIVEN NUMBER IS EVEN OR ODD
echo "Enter the number"
read n
if test `expr $n \% 2` -eq 0
then
echo "$n is even"
else
echo "$n is odd"
OUTPUT
[eceb33@linuxserver eceb33]$ sh odd
Enter the number
34
34 is even
[eceb33@linuxserver eceb33]$ sh odd
Enter the number
73
73 is odd
No comments:
Post a Comment