Professional Documents
Culture Documents
Output-
a=10
b=20
c= `expr $a +$b`
echo $c
output-
30
32
Write a program to multiply two numbers:-
echo ”enter a”
read a
echo ”enter b”
read b
c= `expr $a \* $b`
output-
enter a
10
enter b
2
multiplication is 20
33
Write a program to check whether a no. is even
or odd:-
read num
if [ $rem –eq 0 ]
then
echo”even”
else
echo”odd”
fi
output-
enter a value
odd
34
a=10
b=20
a= `expr $a +$b`
echo ”a”
echo ”b”
output-
intial value of a 10
intial value of b 20
20
10
35
b=20
c=$a
$a=$b
$b=c
output-
interchanging value 20
interchanging value 10
36
read r
echo ”area”$area
output-
enter r
1
area 3.14
37
Write a program of area of Circumfrance:-
echo ”enter r”
read r
echo “enter p”
read p
output-
enter r
1
enter p
2
area 4
38
Write a program to calculate Simple interest:-
echo ”enter t”
read t,
echo ”enter r”
read r
echo ”enter p”
read p
output-
enter t
enter p
enter p
20000
answer is 400
39
Write a program to find out greater between
three variables:-
echo ”enter a”
read a
echo ”enter b”
read b
echo ”enter c”
read c
if [ $a –gt $b –a $a –gt $c ]
then
echo”a is greater”
elif [ $b –gt $c ]
then
echo”b is greater”
else
echo”c is greater”
fi
output-
40
enter a
enter b
enter c
c is greater
41
Write a program to find out greater between the
two:-
echo”enter a”
read a
echo”enter b”
read b
if [$a –gt $b ]
then
echo”a is greater”
else
echo”b is greater”
fi
output-
enter a
enter b
b is greater
42
Write a program whether a no. is prime or not:-
echo”enter a no”
read n
x=2
y=0
do
rem=`expr $n%$n`
if [ $rem –eq 0 ]
then
y=1
fi
x=`expr $x+1`
done
if [$y –ne 1 ]
then
echo”prime”
else
43
echo”not prime”
fi
output-
enter a no
26
not prime
44
Write a program whether a no.is palindrome or
not:-
echo ”enter a no.’
read n
temp=$n
sum=0
do
d=`expr $temp%10`
temp=expr $temp/10
done
if [ $sum – eq $n ]
then
echo”palindrome”
elso
echo”not palindrome”
fi
45
output-
enter a no
555
Palindrome
46
Write a program of Sum of digits:-
echo”enter a no.”
read n
sum=0
while [ $n –ne 0 ]
do
d=`expr $n%10`
n=`expr $n/10`
done
output-
enter a no
123
the sum is 6
47