• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Factorial,Greatest Number,String Palindrome Shell code

April 4, 2011 by ProjectsGeek Leave a Comment

Factorial,Greatest Number,String Palindrome using Shell Programming

 

Menu driven program for Factorial,Greatest Number,String Palindrome

 

a) Find factorial of a no.

b) Find greatest of three numbers

c) Find a prime no

d) Find whether a number is palindrome

e) Find whether a string is palindrome

 Factorial,Greatest Number,String Palindrome Shell Programming Code

 

palins()  
 {  
   echo “ Enter a String to check for Palindrome “  
   read str  
   i=1  
   y=`echo $str | wc -c`   
   y=`expr $y - 1`  
   z=$y  
   echo “The Length of String $y”  
   while [ $y -ne 0 ]  
   do  
   z=`echo $str | cut -c $i`  
   w=`echo $str | cut -c $y`  
   if [ "$z" != "$w" ]  
   then  
   echo “ The Given String $str is not Palindrome ”  
   y=0  
   else  
   i=`expr $i + 1`  
   y=`expr $y - 1`  
   fi  
   done  
   if [ "$z" = "$w" ]  
   then  
    echo “The Given String $str is a Palindrome”  
   fi  
 }  
 palinn()  
 {  
  echo -n "Enter number : "  
  read n  
  sd=0  
  rev=""  
  on=$n  
  while [ $n -gt 0 ]  
  do  
   sd=$(( $n % 10 )) # get Remainder  
   n=$(( $n / 10 )) # get next digit  
   rev=$( echo ${rev}${sd} )  
  done  
  if [ $on -eq $rev ];  
  then  
   echo "Number is palindrome"  
  else  
   echo "Number is NOT palindrome"  
  fi  
 }  
 great()  
 { echo "enter first number"  
  read a1  
  echo "enter first number"  
  read a2  
  echo "enter first number"  
  read a3  
  if [ $a1 -gt $a2 ] && [ $a1 -gt $a3 ]; then  
  echo "first number $a1 is greatest"  
  elif [ $a2 -gt $a1 ] && [ $a2 -gt $a3 ]; then  
  echo "second number $a2 is greatest"  
  elif [ $a3 -gt $a1 ] && [ $a3 -gt $a2 ]; then  
  echo "third number $a3 is greatest"  
  fi  
 }  
 fact()  
 {  
  echo "enter the number to find the factorial"  
  read b  
  c=1  
  while [ "$b" -gt 0 ]; do  
  c=$(($c * $b))  
  b=$(($b-1))  
  done  
  echo "factorial is $c "  
 }  
 clear  
 echo "1. factorial "  
 echo "2. greatest number "  
 echo "3. palindrome "  
 echo "4. palindrome string "  
 echo "5. exit"  
 echo "6. enter ur choice "  
 read d  
 case "$d" in  
 1) echo " factorial "  
   fact;;  
 2) echo "greatest"  
   great;;  
 3) echo "palindrome"  
    palinn ;;  
 4) palins ;;  
 5) ;;  
 * ) echo "enter right choice"  
 esac

 

 

Other Projects to Try:

  1. Factorial,Greatest Number, Palindrome AWK
  2. string operations such as Copy, Length, Reversing, Palindrome, Concatenation
  3. Student Database using Shell Programming OS problem
  4. String Operations with Pointers
  5. Student Database using AWK Programming

Filed Under: Operating System . Linux Assignments

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy