0% found this document useful (0 votes)
12 views1 page

Unix Lab 5-8

Unix programming language

Uploaded by

Ishaaq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Unix Lab 5-8

Unix programming language

Uploaded by

Ishaaq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Program 5 – Fibonacci Program 7 – Armstrong Number

echo "Enter a number to be


a=-1 checked: "
b=1 read num
for I in 0 1 2 3 4 5 6 7 8 9 10 len=${#num}
do sum=0
c=`expr $a + $b` for (( i=0; i<$len; i++ ))
echo $c do
a=$b digit=${num:i:1}
b=$c powered=$(( digit ** len ))
done sum=$(( sum + powered ))
done
Program 6 – Over Time Pay if [ $sum -eq $num ]
then
echo “Overtime Pay Calculation” echo "$num is an Armstrong
echo “___________________” number."
echo “Enter the No.of OT Hours” else
read n echo "$num is not an Armstrong
echo “Enter the pay per hour” number."
read p Fi
ot=`expr $n \* $p`
echo “The OverTime Pay for” $n
“Hours is” $ot

Program 8 – Prime Number If [ $ans -eq 0 ]


Then
Echo -e “Enter Number : \c” Echo “$n is not a prime number.”
Read n Exit 0
While [ $n -gt 2 ] Fi
Do Done
For ((i=2; i<=$n/2; i++)) Done
Do Echo “$n is a prime number.”
Ans=$(( n%i ))

You might also like