Find max and min no.from numbers passed through command line, Programming Languages

10.     W.A.S.S to find maximum and minimum number from numbers passed through command line.

 

Program

 

# W.A.S.S to find maximum and minimum number from numbers passed through command #line.

 cnt=$#

# //$# gives the count of total number of command line arguments

 

if [ $cnt -gt 0 ]

then

min=$1

max=$1

 for i in $* # $* stores the command line arguments

 do

  if [ $i -gt $max ]

  then

   max=$i

  elif [ $i -lt $min ]

  then

   min=$i

  fi  

 done

 

echo "Minimum is : $min"

echo "Maximum is : $max"

else

 echo "Enter the command arguments properly:"

fi

 

Output

 

sh cmdline.sh 23 12 45

Minimum is : 12

Maximum is : 45

Posted Date: 9/26/2012 7:53:10 AM | Location : United States







Related Discussions:- Find max and min no.from numbers passed through command line, Assignment Help, Ask Question on Find max and min no.from numbers passed through command line, Get Answer, Expert's Help, Find max and min no.from numbers passed through command line Discussions

Write discussion on Find max and min no.from numbers passed through command line
Your posts are moderated
Related Questions
Calculate the total price to purchase all the components required to build a state-of-the-art gaming computer from components available on the internet. Before attempting this exer

We need help for build a Price Quote Generator I am interested in two things (A) a web based system that will allow a user to enter the parameters of their contests (there are o

A non-empty string β is called a repeat pre x of a string s if ββ is a pre x of s. Give a linear time algorithm to find the longest repeat prefix of s. Hint: Think of using lca

Do you do APL programs ?

I need help programming an arduino uno to scan an ean-8 student barcode and display their name and id on computer. This is a capstone project.

In the procedure section, it is important to have a clear circuit diagram with component values and a brief, but accurate description of each step taken. 1. Tables for both the

Assignment is to create hijara game on any plate form, you can use any plate form you like or easy to you. For instance let's say you can use visual studio, game studio (Prefer to

The following is the process an account holder of eBroker, a discount online brokerage firm, uses to sell stocks.  The user first logs in by entering the username and password.

Figure is a representation of the solar system. In a basic model of the same concentric orbits planets rotate around the sun. The closer the Planet in less time Sun completes a ful

What will be the output for the following instruction if CX=9087H and AX=9090H? 1) BTR AH,2? 10010000=10010000 2) BTC CX,9?1001000010000111=1001000110000111 3) NEG AX?