Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Thursday, June 02, 2011

Calculation

#!/bin/sh
if [ $# -ne 2 ]
then
echo "Please Enter 2 Numbers !!! "
else
echo "Enter First Number : "
read a
echo "Enter Second Number : "
read b
c=echo "Enter The Operation You want To Calculate : "
echo "+ For Addition"
echo "- For Subtraction"
echo "* For Multiplication"
echo "/ For Division"
case $d in
+) c=$( expr $a + $b )
-) c=$( expr $a - $b )
*) c=$( expr $a \* $b )
/) c=$( expr $a / $b )
esac
echo "The Answer is : " $c
exit 0

Saturday, May 07, 2011

Fibbonacci(LINUX)

#!/bin/sh
echo "Enter the Number :"
read a
echo "Enter Second Number :"
read b
i=1
echo "enter The Number of Terms :"
read n
echo "Fibonacci Series of The Entered Number is "
echo $a
echo $b
while [ $i -le $( expr $n - 2 ) ]
do
c=$( expr $a + $b )
i=$( expr $i + 1 )
echo $c
a=$b
b=$c
done
exit 0