Tuesday, February 22, 2011

Simple Linux Program



This is a program related to addition ,subtraction,Multiplication and division of two number .coding of program is given below .write it on terminal ,then save the file,make executable file using chmode command .
Coding is: 
                                           
echo Enter First Number
read num
echo Enter Second Number
read num1

while true
do
 printf "\t***MENU***\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division \n5.Exit\n\tEnter your choice:"
read ch

 case $ch in
1) add=`expr $num + $num1`
   echo Addition is $add
   ;;

2) sub=`expr $num - $num1`
   echo Subtraction is $sub
   ;;

3) mul=`expr $num \* $num1`
   echo Multiplication is $mul
   ;;

4) div=`expr $num / $num`
   echo Division is $div
   ;;


*) echo Coming Out Of Program!!!!!
   exit
 esac
done
 

No comments:

Post a Comment