Professional Documents
Culture Documents
Name: Najib Mahmud Id: 173-15-928 Anstotheqno1
Name: Najib Mahmud Id: 173-15-928 Anstotheqno1
Name: Najib Mahmud Id: 173-15-928 Anstotheqno1
ID: 173-15-928
Ans to the Q No 1
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
(( $D > 0 )) && printf '%d days ' $D
(( $H > 0 )) && printf '%d hours ' $H
(( $M > 0 )) && printf '%d minutes ' $M
(( $D > 0 || $H > 0 || $M > 0 )) && printf 'and '
printf '%d seconds\n' $S
}
Ans to the Q no 2
number=1
rows=5
for((i=1; i<=rows; i++))
do
for((j=1; j<=i; j++))
do
echo -n "$number "
number=$((number + 1))
done
number=1
echo
done
Ans to the Q no 3
Ans to the Q no 4
Ans to the Q no 5
Clear
echo "enter purchase amount"
read pa
if [ $pa -lt 1000 ]
then tax='echo $pa \* 2 /100 | bc'
discount='echo $pa \* 10 / 100 | bc'
else tax='echo $pa \* 5 /100 | bc'
discount='echo $pa \* 20 / 100 | bc'
fi
amount='expr $pa + $tax - $discount'
echo cash payment =$amount
Ans to the Q no 6
7.