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

Lab 1

The document contains three shell script programs. The first program calculates the sum of two user-input numbers, the second finds the greatest among three integers, and the third determines the larger of two integers. Each program prompts the user for input and displays the result accordingly.

Uploaded by

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

Lab 1

The document contains three shell script programs. The first program calculates the sum of two user-input numbers, the second finds the greatest among three integers, and the third determines the larger of two integers. Each program prompts the user for input and displays the result accordingly.

Uploaded by

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

Q1wap to addition of two numbers?

# Take input from user and calculate sum.


read -p "Enter first number: " num1
read -p "Enter second number: " num2

# Calculate sum
sum=$(( $num1 + $num2 ))

# Display the result


echo "Sum is: $sum"

Q2 write a program to find greatest number in three digit?


echo "Enter three Integers:"
read a b c
if [ $a -gt $b -a $a -gt $c ]
then
echo "$a is Greatest"
elif [ $b -gt $c -a $b -gt $a ]
then
echo "$b is Greatest"
else
echo "$c is Greatest!"
fi

----------------------------------------------
Q3 write a program to find greatest number in two digit?

echo "a shell script to find out the large between two number."
echo -n "Enter First number"
read n1
echo -n "Enter Second number"
read n2
if test $fst_num -gt $snd_num
then
echo $fst_num is greater than $snd_num.
else
echo $snd_num is greater than $fst_num.
fi

You might also like