Name: Najib Mahmud Id: 173-15-928 Anstotheqno1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name: Najib Mahmud

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

echo "Enter Num1"


read num1
echo "Enter Num2"
read num2
echo "Enter Num3"
read num3

if [ $num1 -gt $num2 ] && [ $num1 -gt $num3 ]


then
echo $num1
elif [ $num2 -gt $num1 ] && [ $num2 -gt $num3 ]
then
echo $num2
else
echo $num3
fi

Ans to the Q no 4

echo "please enter Basic Salary"


read basic
echo "please enter your HRA"
read HRA
echo "please enter your TA"
read TA
echo "please enter your OA"
read OA
DA echo = "scale=3, $basic*0.14" | bc
PF echo = "scale=3, $basic*0.12" | bc
IT echo = "scale=3, $basic*0.15" | bc
echo "DA is: $DA"
echo "PF is: $PF"
echo "TA is: $IT"
Ns = echo "scale=3: $basic + $DA + $HRA + $TA + $OA + : bc
echo "Net salary: $ NA "

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

read -p "Enter first number: " num1


read -p "Enter second number: " num2
sum=$(( $num1 + $num2 ))
echo "Sum is: $sum"

7.

You might also like