Untitled Document
Loop Control Structure
1. Program - To find factorial of any number entered through keyboard Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # 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 a Number $num is : $x "
       
2. Program - Enter any two numbers and write a program to find value of one number raise to power of other Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To Raise To a Number 
       
       echo " Enter A Number "
       read num 
       
       echo " Enter To the power we need to raise it "
       read pow
       
       x=1
       
       for ((i=1 ; i<=$pow ; i++ ))
              {
                let x=$num * $x
               } 
       echo " $num raise to power of $pow is : $x "
       
3. Program - To Print table of value(number) entered through keyboard Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To Print Table of Any Number
       
       echo " Enter Any Number "
       read num 
             
       x=1
       
       for ((i=1 ; i<=10 ; i++ ))
              {
                let x=$num * $i
                echo " $num * $i is = $x "
               } 
       
       
4. Program - To Print nos as 5,4,3,2,1 using while loop Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program To Print nos as 5,4,3,2,1 using while loop
       
          i=5 

         while test $i != 0
         do
	       echo "$i"
	       i=`expr $i - 1` 
         done 
      
5. Program - To Read and print all the lines from a file using while loop Click Here
       #!/bin/ksh 
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - To Read and print all the lines from a file using while loop
       
       echo " Enter any file name "
       read file_name 
          
         while read line 
         do
	       echo "$line"
	     done < $file_name 
      
Untitled Document