echo "Enter three numbers " read a b c if [ $a -gt $b -a $a -gt $c ] then echo " A is big " elif [ $b -gt $c ] then echo " B is big " else echo " C is big " fi
OUTPUT
[1csea56@local host~]$ sh biggest.sh
3 4 9
C is big
[1csea56@local host~]$ sh biggest.sh
7 5 2
A is big
RESULT:
Thus a program has been written in the UNIX successfully to find the biggest of three numbers and the output is verified.
//FIBONACCI SERIES echo "enter the number" read n f=0 a=0 b=1 i=0 while [ $i -le $n ] do f=`expr $a + $f` a=`expr $b` b=`expr $f` i=`expr $i + 1` echo $f done OUTPUT
[1csea56@local host~]$ sh fib.sh
Enter the number
5
0
1
1
2
3
RESULT
Thus a program to perform Fibonacci series was written and executed successfully.
// FACTORIAL OF A NUMBER echo "Enter the value” read n i=1 f=1 while [ $i -le $n ] do f=`expr $f \* $i` i=`expr $i + 1` done echo "Factorial Of $n is:$f"
OUTPUT
[1csea56@local host~]$ sh factorial.sh
Enter the number
4
Factorial of 4 is: 24
RESULT Thus a program to find factorial of a number was written and executed successfully.
// Palindrome program
len=0 i=1 echo “enter the string” read str len=`echo $str|wc -c` len=`expr $len - 1` halflen = `expr $len/2` while [ $i –le $halflen ] do c1= `echo $str|cut -c $i` c2= `echo $str|cut -c $len` if [ $c1! = $c2 ] then echo “ string not palindrome” exit fi i=`expr $i +1` len = `expr $len -1` done echo “string is palindrome”
OUTPUT
[1csea56@local host~]$ sh palindrome.sh
Enter the