MCA World :: Computer Application ::
Questions :  Answers : Solutions of TMA & Project Assignment  of  MCA courses of IGNOU, NIT & Other Universities.

::: Shell Programming



Home • Introduction to Software • Data Structures • System Engineering • Database Management System • Discrete Mathematics • Numerical & Statistical Computing • Software Engineering • Operation Research • Accounting & Finance • Computer Architecture • Operating Systems • Intelligent Systems • Relational Database • Obejct Oiented Systems

Shell Programming

Up • Regular Expression • Shell Programming

Main Chapters

Home
Introduction to Software
Data Structures
System Engineering
Database Management System
Discrete Mathematics
Numerical & Statistical Computing
Software Engineering
Operation Research
Accounting & Finance
Computer Architecture
Operating Systems
Intelligent Systems
Relational Database
Obejct Oiented Systems

Shell Programming

Question 2:  Write shell program for the following

a)      To remove from an ordered array all numbers that occurs more than  once.

b)      To check whether a string is palindrome or not.

c)      To sort the given list of numbers using bubble sort.

Ans :

Shell Programs to Remove duplicate members of a sorted/ordered array

# Shell Programs to Remove duplicate members of a sorted/ordered array

echo “Enter Total Numbers in the Array”

read tot

i=1

while [ $i  –le $tot ]

do

echo “Enter the Sorted ordered array number - $i”

read num$i

i=`expr $i + 1`

done

i=1

y=${num$i}

echo $y

i=2

flag=0

while [ $i  –le $tot ]

do

z=${num$i}

if [ $y –ne $z ]

then

flag=`expr $flag + 1`

sort$flag=$z

y=$z

fi

i= 'expr $i + 1`

done

i=1

echo “Unique set of numbers”

while [ $i –le $flag ]

do

echo ${sort$i}

i=`expr $i + 1`

done

 

Shell Program for strings for Checking of Palindrome

# Shell Program for strings for Checking of Palindrome

echo “Enter a String to check for Palindrome “

read str

i=1

y=`expr  $str  |  wc  –c`

y=`expr  $y  –  1’

z=$y

echo “The Length of String $str = $y”

while  [ $y  –ne  0 ]

do

z=`expr  $str  |  cut  –c $i`

w=`expr $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

Shell Programming – Bubble Sort

#  Shell Programming – Bubble Sort

echo “Enter Total Numbers to be sorted ”

read tot

i=1

while [ $i  – le  $tot ]

do

echo “Enter the Number $i   =  ”

read  nm$i

i=`expr $i  +  1`

done

m=1

while [ $m  –le  $tot ]

do

n= `expr  $m  +  i`

while [  $n  –le  $tot  ]

do

if  [  ${nm$m}  –gt  ${nm$n} ]

then

a=${nm$m}

nm$m=${nm$n}

nm$n=$a

fi

n=`expr $n + 1`

done

m=`expr $m + 1`

done

echo “ Listing of Sorted Array “

k=1

while [ $k  –le  $tot ]

do

echo "The sorted number $k is ${nm$k}"

k=`expr  $k  +  1`

done

Up ] Regular Expression ] [ Shell Programming ]

Links for Web Developers Web Publishers

 

Links from Google

 

 
 


Home • Introduction to Software • Data Structures • System Engineering • Database Management System • Discrete Mathematics • Numerical & Statistical Computing • Software Engineering • Operation Research • Accounting & Finance • Computer Architecture • Operating Systems • Intelligent Systems • Relational Database • Obejct Oiented Systems



This is complete MCA study materials containing question, solutions, answers, programming, scripts, TMA, Project assignment solutions for aspiring MCA or BCA student. This website may be useful for all in general and IGNOU student in particulars. Disclaimer : Execution and correctness of programs/answers may be established by the users himself and the mcaworld.net shall not held responsible for any damage/loss caused due to the use of code over this site.



Webmaster Bipin Bihari Pandey, An IT Expert of DotNet Technology, MCA from IGNOU
bipin9830@rediffmail.com or bipin9830@yahoo.com