Documente Academic
Documente Profesional
Documente Cultură
CLASS:-SYIT/B
ROLL NO:-2532
ASSIGNMENT NO 6
1
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
2
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
3
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
Q.4 Write a program to find area of circle, triangle, rectangle
and squares?
Ans:[student@Lab1 sachin2532]$ vi area2532.sh
echo "enter the number"
read r
read p
circ=`expr $p \* $r \* $r`
echo $circ
echo "enter the base"
read b
echo "enter the height"
read h
read d
triangle=`expr $d \* $b \* $h`
rectangle=`expr $b \* $h`
echo $triangle
echo $rectangle
echo "enter the sides"
read s
squares=`expr $s \* $s`
echo $squares
~
~
~
~
~
~
~
~
~
~
~
-- INSERT -- 14,16 All
[student@Lab1 sachin2532]$ sh area2532.sh
enter the number
2
3
12
4
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
enter the base
4
enter the height
2
1
8
8
enter the sides
4
16
5
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
Q.6 Write down the shell program enter the character from the user
and find out whether it is a digit, capital letter or small letter or a
symbol?
Ans:[student@Lab1 sachin2532]$ vi character.sh
echo "enter any character"
read ch
case $ch in
[0-9]) echo "it is a digit"
;;
[A-Z]) echo "it is a capital letter"
;;
[a-z]) echo "it is small letter"
;;
[*]) echo "it is a symbol"
;;
esac
~
~
~
~
~
~
~
~
~
~
-- INSERT -- 0,1 All
E138: Can't write viminfo file /home/student/.viminfo!
6
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
Q.7 Write a shell script to check whether word begins with small case
vowel or capital case vowel or ends with any digit?
Ans: [student@Lab1 sachin2532]$ vi vowel.sh
echo "enter any vowel"
read v
case $v in
[aeiou]*) echo "it is a small case"
;;
[AEIOU]*) echo "it is a capital case"
;;
*[0-9]) echo "it is a digit"
;;
esac
~
~
~
~
~
~
~
-- INSERT -- 0,1 All
E138: Can't write viminfo file /home/student/.viminfo!
Hit ENTER or type command to continue
[student@Lab1 sachin2532]$ sh vowel.sh
enter any vowel
a
it is a small case
[student@Lab1 sachin2532]$ sh vowel.sh
enter any vowel
E
it is a capital case
7
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
Q.8 Write a shell script for to find factorial of a number?
Ans: [student@Lab1 sachin2532]$ vi facts32_2.sh
echo "enter a number"
read a
fact=1
i=0
while [ $i -lt $a ]
do
i=` expr $i + 1`
fact=` expr $fact \* $i`
done
echo "factorial of number is"
echo $fact
~
~
~
~
~
~
~
-- INSERT -- 12,1 All
"facts32_2.sh" [New] 13L, 153C written
E138: Can't write viminfo file /home/student/.viminfo! 11,11 All
Hit ENTER or type command to continue 10,30 All
[student@Lab1 sachin2532]$ sh facts32_2.sh
enter a number
5
factorial of number is
120
[student@Lab1 sachin2532]$ sh facts32_2.sh
enter a number
4
factorial of number is
24
8
NAME:-SACHIN HARIBA METKARI
CLASS:-SYIT/B
ROLL NO:-2532
Q.9 Write a program in a shell script to check whether it is Armstrong
or not?
Ans:- [student@Lab1 sachin2532]$ vi arms2532.sh
echo "enter any number"
read num
sum=0
temp=$num