Q2.WAP Accept N-Digit Number and Display It in Words. Answer
Q2.WAP Accept N-Digit Number and Display It in Words. Answer
Q2.WAP Accept N-Digit Number and Display It in Words. Answer
Answer:
#!/bin/bash
#Exp2.sh
case $Q in
1) echo " One " ;;
2) echo " Two " ;;
3) echo " Three " ;;
4) echo " Four " ;;
5) echo " Five " ;;
6) echo " Six " ;;
7) echo " Seven " ;;
8) echo " Eight " ;;
9) echo " Nine " ;;
0) echo " Zero " ;;
esac
done
echo "MENU"
echo "1. ADD"
echo "2. SUBTRACT"
echo "3. MULTIPLY"
echo "4. DIVIDE"
echo "5. REMAINDER"
echo "6. EXIT"
read case
case $case in
1)a=`expr $x + $y`
echo "$a" ;;
2)a=`expr $x - $y`
echo "$a" ;;
3)a=`expr $x \* $y`
echo "$a" ;;
4)a=`expr $x / $y`
echo "$a" ;;
5)a=`expr $x % $y`
echo "$a" ;;
6)exit
esac
1. * 1
** 11
*** 111
**** 1111
***** 11111
Answer:
#!/bin/bash
#Exp8.1.sh
12
123
1234
12345
Answer:
#!/bin/bash
#Exp8.2.sh
3. 1
22
333
4444
55555
Answer:
#!/bin/bash
#Exp8.3.sh
#!/bin/bash
MAX_NO=0
clear
5. *
**
***
****
*****
****
***
**
*
Answer:
#!/bin/bash
#Exp8.5.sh
while(true)
do
tput clear
tput cup 1 0
x=`date "+ %H:%M:%S"`
echo $x
if test $d -lt 12
then
echo "Good Morning"
Answer:
#!/bin/bash
#Exp10.1.sh
first=0
second=1
echo "enter the length of fibonacci series"
read n
echo "fibonacci series is:"
echo $first
echo $second
for((i=0;i<n-2;i++))
do
let third=$first+$second
first=$second
second=$third
echo $third
done
Q10.3.WAP For Factorial.
Answer:
#!/bin/bash
#Exp10.2.sh
echo"Enter a character"
read c
lc=0
uc=0
sc=0
case $c in
[a-z]) echo "It is lowercase letter";;
lc = `expr $lc + 1`
[A-Z]) echo "It is uppercase letter";;
[0-9]) echo "It is a number";;
?) echo "It is a special case letter";;
esac
Q12.Script To Check the Content Of Two Files For Similarities And If
Same Then Delete Second File
Answer:
#!/bin/bash
#Exp12.sh
if (cmp $1,$2)
echo "Content of the file are same"
rm $2
else
echo "Content of the file are different"
fi
declare arr[$n]
for((i=0;i<$n-1;i++))
do
for((j=$i+1;j<$n;j++))
do
if [ ${arr[$i]} -gt ${arr[$j]} ];then
let temp=${arr[$i]}
let arr[$i]=${arr[$j]}
let arr[$j]=$temp
fi
done
done
printf "Sorted List Is : "
for((k=0;k<n;k++))
do
printf "${arr[$k]} "
done