Professional Documents
Culture Documents
ASAD IKRAM
17K3943
A
PROBLEM 1
Addition()
PROBLEM 2
LargestNum()
{
echo "Enter 3 numbers to find the largest"
read num1 num2 num3
then
echo "$num2 is Larger than $num1 and $num3"
then
echo "$num3 is Larger than $num1 and $num2"
else
echo "same"
fi
}
LargestNum
PROBLEM 5
Detail()
{
echo "Current Date:"
date
echo "Username:"
whoami
pwd
}
Detail
PROBLEM 3
#!/bin/bash
echo "1 for + "
echo "2 for - "
echo "3 for * "
echo "4 for / "
case $input in
pattern-1)
Result=$(( num1+num2 ))
echo $Result
;;
pattern-2)
echo Result=$(( num1-num2 ))
;;
*)
echo "unknown"
;;
Esac
PROBLEM 4
#!/bin/bash
echo "Enter first number: "
read num1
sum=0
while [ $num1 -gt 0 ]
do
a=$(( $num1 % 10 ))
num1=$(( $num1 / 10 ))
sum=$(( $sum + $a ))
done
echo "SUM IS: $sum"