Untitled Document
Case Control Structure

1. Program - Menu Driven program which has following options

  1. Factorial Of number
  2. Prime Or Not
  3. Odd or even
  4. Table of a number
  5. Exit

Click Here

       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Menu Driven program which has following options
       
       echo "This is a Menu Driven program , Please select following Options"
       
            echo " . . . . . MENU . . . . . "
            echo " 1 . Factorial Of Number "
            echo " 2 . Prime Number Or Not "
            echo " 3 . Odd Or Even "
            echo " 4 . Table Of A Number "
            echo " 5 . Exit "
            
         echo " Enter Your Choice "
         read option
         
         case "$option" in
         
               1) # Program To Find Factorial Of a Number 
                     echo " Enter Any Number"
                     read num 
                     
                       x=1
                            for (( i=1;i<=$num;i++))
                              {
                                let x=$x*$i
                              } 
                      echo "Factorial Of Number $num is :: $x "
                      ;;
                      
                3) # Program To Find the number Is Odd Or Even  
                     echo " Enter Any Number"
                     read num 
                     
                       
                       if [[ $num%2 -eq 0 ]]
                            then 
                              echo "The Number $num is even number"
                            else
                              echo " The Number $num is odd number"
                       fi
                      ;;
                      
                 4) # Program To Print Table Of a Number 
                     echo " Enter Any Number"
                     read num 
                     
                       x=1
                            for (( i=1;i<=10;i++))
                              {
                                let x=$num*$i
                                echo " $num * $i = $x "
                              } 
                      ;;
                      
                  5) exit ;;
                     esac         
           
    
2. Program - Menu Driven program which has following options
  1. Display Today's date in ( dd-mm-yyyy)
  2. list of files from a path
  3. Exit
Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Menu Driven program which has following options
       
       echo "This is a Menu Driven program , Please select following Options"
       
            echo " . . . . . MENU . . . . . "
            echo " 1 . Displays Today's Date in (dd-mm-yyyy) "
            echo " 2 . List Of Files From A Patch "
            echo " 3 . Exit "
                       
         echo " Enter Your Choice "
         read option
         
         case "$option" in
         
               1) date +"%d-%m-%Y"
                  ;;       
               
               2) ls -l 
                  ;;
                  
               3) exit 
                  ;;
                  
                  esac   
                  
3. Program - Menu Driven program which has following options for mathematical calculations
  1. + addition
  2. - subtraction
  3. x multiplication
  4. / division
Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Menu Driven program which has following options
       
       echo "This is a Menu Driven program , Please select following Options"
       echo " . . . . . MENU . . . . . "      
           
           if test $# = 3
           then
	          case $2 in
	          +) let z=$1+$3;;
	          -) let z=$1-$3;;
	          /) let z=$1/$3;;
	          x|X) let z=$1*$3;;
	          *) echo Warning - $2 invalied operator, only +,-,x,/ operator allowed
	             exit;;
	          esac
	
             echo Answer is $z
           else
	         echo "Usage - $0   value1  operator value2"
	         echo "        Where, value1 and value2 are numeric values"
	         echo "        operator can be +,-,/,x (For Multiplication)"
                 echo "        for example to sum two digit input will be like this - 2 + 3 "
             
           fi
          
Untitled Document